REDWOOD CITY (BCN)—A man who was shot by a San Francisco police officer while attempting to carjack drivers near San Francisco International Airport last year was sentenced to over 3 years in prison today, prosecutors said.

Daniel Frederick, 25, was sentenced to 3 years and 2 months in prison by Judge Elizabeth Lee today, the maximum sentence stipulated in a plea deal reached with prosecutors in April, San Mateo County Deputy District Attorney Karen Guidotti said.

Frederick will only serve about a year of that sentence as he already has 789 days credit for time served, Guidotti said.

He pleaded guilty to attempted kidnapping and vehicle theft in April. Prosecutors had originally charged Frederick with seven counts for a series of alleged crimes on July 26, 2015, that ended with him being shot in the abdomen by police.

Frederick stole a Toyota Yaris from the Millbrae BART station at about 6:50 a.m. that day while its owner was running the San Francisco Marathon. He quickly crashed the car into a light pole on South Airport Boulevard near the North Access Road to the airport.

He walked away from the crashed car and hid nearby, shedding his jacket and emerging wearing a yellow T-shirt. A police officer on a motorcycle noticed him and tried to talk to him. After a few minutes, the officer ordered Frederick to put down a backpack he was holding but Frederick ran away, heading west on San Bruno Avenue, prosecutors said.

Frederick then jumped into a car stopped at a stoplight and threatened the driver, ordering him to drive away. The police officer caught up with him and, thinking the driver might be an accomplice, ordered him at gunpoint not to go anywhere. The driver put his hands up and refused to help the suspect escape.

Frederick ran again, taking the driver’s backpack with him. He fled down a dirt road and hid in some bushes near U.S. Highway 101. Several other officers found Frederick in the bushes and ordered him out. Eventually he fled again and tried to get into several other cars parked along a frontage road there but couldn’t.

An officer again ordered him to stop at gunpoint. Frederick turned toward him and started approaching. The officer, whose name has not been released, fired one shot but missed and Frederick kept coming, saying “shoot me, kill me” as he approached, prosecutors said. The officer shot him in the abdomen.

He spent three days recovering in the hospital before he was booked into jail, prosecutors said.