SANFORD — A Biddeford man who held up Walgreens on Tuesday and then attempted to carjack two vehicles in his getaway was apprehended within minutes, thanks to the quick response of Sanford police officers.

Brian A. Gallerani, 27, of Biddeford, was charged with three counts of armed robbery in connection with the Jan. 8 robbery of the pharmacy at 868 Main Street.

According to a press release from Sanford Police Chief Thomas P. Connolly, a male entered Walgreens at about 12:30 p.m., walked to the store’s pharmacy consultation area, lifted up his sweat shirt to reveal a handgun, and demanded prescription drugs from the pharmacy employee.

After obtaining drugs, the man fled from the store on foot and was seen running down Acorn Street, toward Riverside Avenue. At the intersection of Acorn and Riverside, the suspect attempted — unsuccessfully — to carjack two vehicles, according to police. One of the vehicles struck the suspect, causing him to drop the handgun and some of the stolen drugs. The suspect then ran toward Winter Street.

Sanford Police patrol officers and detectives responding to the area of the robbery located the suspect and apprehended him without incident behind a house on Winter Street.

“Sanford officers were assisted by at least two citizens who saw the suspect fleeing the scene of the attempted carjackings, and directed police to the area where the suspect was eventually apprehended,” Connolly said.

Gallerani was in custody about 10 minutes after police were alerted to the robbery “due to the rapid and focused response of the officers,” Connolly said.

In addition to the armed robbery charges, Gallerani is charged with a probation violation. He is being held at the York County Jail and his bail has been set at $25,000 according to a jail official.

Connolly said the Federal Bureau of Investigation, Portland Field Office, will be working with Sanford Police on the investigation.