A New Hampshire man who rode his bike to Maine and robbed a pharmacy in Kittery at knifepoint last year pleaded guilty Monday in federal court in Portland to interference with commerce by robbery.

Robert Pecora, 25, of Dover, N.H., also pleaded guilty to criminal contempt for running away from a drug treatment program last month while he was free on bail for the drugstore robbery, and stealing guns, cash and a vehicle.

Pecora showed a knife to an employee at the Rite Aid on Shapleigh Road in Kittery on Sept. 21 and demanded “all of your Oxycontin.” He was given three bottles of pills and then shut himself in the store’s bathroom until police arrived, according to court records.

Pecora told Kittery police at the scene that he had robbed the store. Officers found light blue pills and pill residue on the bathroom floor and a light blue powdery residue on Pecora’s upper lip, according to an affidavit filed in his case by FBI Agent Thomas MacDonald.

Months after his arrest, the court allowed Pecora to be released on an unsecured bond of $5,000 so he could enter the Addiction Recovery Center in Dover, N.H., with a condition that he not leave the facility without permission from the U.S. Probation Office.

Pecora fled the facility on March 20 and broke into a home in Greenland, N.H., that night. He stole three firearms, about $1,000 in cash and a vehicle from the house and remained at large until he was arrested on March 25 in Keene, N.H., according to a prosecution document filed in federal court Monday.

Pecora is scheduled to be sentenced in both cases on July 30. He faces up to 30 years in prison and a fine of $250,000 in the drugstore robbery. He faces an additional prison term of up to 10 years in the contempt case on top of the sentence he gets in the robbery case.

Scott Dolan can be contacted at 791-6304 or at:sdolan@pressherald.comTwitter: @scottddolan