Investigator Brandon Rollins, 33, is in stable condition at an area hospital, the Sheriff's Office said on Friday.
Rollins and two other officers were at the Shrimp Boat Restaurant on Memorial Park Road in Lancaster during their meal break on Thursday night when an armed man came in and demanded money, the Sheriff's Office said.
The owner of the Shrimp Boat, Teresa Jenkins, said the three officers acted quickly.
"They got our customers and our help under the table," she said. "They protected them. They just were awesome."
Sheriff Barry Faile said the officer confronted the man, whom they identified as 19-year-old Rodrick Caskey.
There was an exchange of gunfire. The Sheriff's Office said Rollins was shot in the stomach and that one of the officers' shots grazed Caskey in the face.
Rollins was airlifted to the hospital.
"He and the others are heroes for what they did," Jenkins said.
Investigators said Caskey ran from the restaurant, and police searched for him for hours before they found him walking on W. Meeting Street, a few miles from the restaurant, and arrested him.
CHOPPER 9: Lancaster Co. deputy shot responding to robbery
SLIDESHOW: Deputies search for person who shot officer
CHOPPER 9: Deputies search for person who shot deputy
He was taken to a local hospital for treatment for non-life-threatening injuries, according to the Sheriff's Office.
Caskey is facing charges of attempted murder and armed robbery.
Because the incident was an officer-involved shooting, the investigation has been turned over to the State Law Enforcement Division. The Lancaster County Sheriff's Office said all three officers on the Lancaster County Drug Task Force Team were wearing plain clothes at the time.
"We are very happy that Investigator Rollins is doing well and we ask that everyone keep Brandon and his family in their thoughts and prayers," Sheriff Barry Faile said. "We are also grateful for all of the agencies that came to our assistance and helped us bring this violent individual to justice."