A Buffalo ex-con was sentenced to eight years in prison this week for first-degree robbery and a drug charge.

Jesse Bonner, 37, of Stockbridge Avenue, had faced up to 25 years in prison after he admitted in July that he robbed two 20-year-olds at gunpoint in October 2011 on Main Street. Bonner then followed the two into an apartment building and stole their personal property, according to the Erie County District Attorney’s Office.

State Supreme Court Justice M. William Boller also sentenced Bonner to five years of post-release supervision.

Two police officers caught Bonner about two hours after the robbery.

Bonner has prior robbery and cocaine-distribution felony convictions, according to prosecutors.