Adam Kibler, 24, was charged with first-degree robbery, police said.
Eastern Niagara Hospital told police the man walked into the emergency room at 4:57 a.m. Saturday and demanded drugs. He was armed with two rifles and claimed to have a bomb, police Chief Michael Niethe said.
Police responded immediately and got there while the suspect was still in the building.
The man made off with some items. Police spokeswoman Julie Snyder told CNN he made off with some prescriptions.
The suspect dropped his weapons and a backpack and fled on foot. One of the officers fired two shots at the suspect. Police don't think he was hit.
A bomb squad determined that an item in a backpack was an inert device.
"We got lucky at that end," Niethe said. "We recovered a lot of evidence at the scene."
Niethe said that the hospital was fully locked down for a number of hours and authorities told residents to shelter in place. Those directives were eventually lifted.
"It took a number of hours to search the area," Niethe said.
Lockport is in Niagara County and is more than 20 miles north of Buffalo.
Images from CNN affiliate WIVB showed a police SWAT team outside the hospital and a helicopter surveying the area.
Police described the suspect as a white male, 6 feet tall with blond hair. He was wearing khaki pants, a khaki shirt and a ski mask.
No injuries were reported as a result of the incident.
The hospital issued a statement saying, "Patients and staff at the facility are safe."