NEW YORK (AP) — State police say a captured fugitive who allegedly fired a gun inside an upstate New York hospital had gone there looking for pain medication.

Police say 42-year-old Joshua Stuart went to the Ellenville Regional Hospital, about 75 miles (120 kilometers) southwest of Albany, early Friday complaining of abdominal pain.

Prosecutors say Stuart fired his gun after a hospital employee declined to give him the meds. They say he then shot up a Demerol dispenser before leaving. He later exchanged gunfire with police and fled the area in a stolen car.

Stuart was captured in Brooklyn on Monday hours after he allegedly robbed a store clerk at gunpoint.

At a court appearance on Tuesday, Stuart's defense attorney said he was a longtime heroin addict.

More From WIBX 950