(KTLA) — A San Bernardino County Sheriff’s Deputy is in stable condition Sunday after he was shot twice during a service call near Rancho Cucamonga.

The deputy was responding for a report of a suspicious vehicle seen near the intersection of Sycamore Court and Wilson Avenue just after midnight.

According to the Sheriff’s Department, the deputy arrived on scene, made contact with the driver and completed a records check, but at some point, the driver pulled out a gun and twice shot the deputy.

The deputy returned fire as the gunman fled on foot, Sheriff’s officials said. While bleeding from his injuries, the deputy was able to radio for help and provide a description of his shooter.

Additional law enforcement officers arrived on scene and a perimeter was set up as authorities searched for the gunman. The deputy, meanwhile, was airlifted to a local hospital for treatment where he is currently in stable condition, Sheriff’s officials said.

Not far from the shooting scene, a man matching the suspect’s description was spotted walking near Chaffey College. Deputies responded to the area and took the man into custody.

He’s been identified as Nicholas Campbell, a 35-year-old man from Northern California.

Sheriff’s officials said Campbell has an extensive criminal history and is currently on parole for carjacking.

Campbell was uninjured in the shooting.

Both guns were recovered from the scene, including the gun Campbell is alleged to have used as well as the deputy’s service firearm.

The injured deputy is a five-year veteran of the San Bernardino County Sheriff’s Department and is based at the Rancho Cucamonga Station. His identity has not been released at this time.

During a press conference Sunday morning, Sheriff Shannon Dicus said he was able to talk to the deputy and thank him for his courage in the line of fire.

“I told him how proud I was of him, and his response and to think about being shot and still being able to put information out to your partners and ultimately take a dangerous suspect into custody,” Dicus said.