PORTLAND, Maine — Less than a month after denying he robbed a convenience store and bank in April with a gun stolen last year from the car of a Cumberland County sheriff’s detective, a South Portland man pleaded guilty Monday in U.S. District Court to charges in connection with both crimes.

Joseph Morrill, 23, pleaded guilty to one count each of bank robbery, aiding and abetting interference with commerce by robbery of a convenience store, use or carrying of a firearm during and in relation to a crime of violence and possession of a stolen firearm.

Morrill was indicted July 10 by a federal grand jury in connection with the April 22 robbery of a TD Bank branch in South Portland of more than $5,600 and the April 17 robbery of a Cumberland Farms store at gunpoint in the same city of more than $182. He pleaded not guilty to the charges July 22.

He has been held without bail at the Cumberland County Jail pending the outcome of his case.

The .40 caliber Glock handgun and a Cumberland County Sheriff’s Office badge were among the items reported stolen Sept. 21 from the vehicle of a detective in South Portland, according to the affidavit filed in federal court. The document did not say whether the car was the detective’s personal vehicle or belonged to Cumberland County.

By pleading guilty, Morrill admitted that he walked into the bank on Market Street in South Portland about 5:30 p.m. April 22, pointed the stolen gun at the teller and demanded money. He fled on foot out the back door of the building, according to the prosecution version of events to which he pleaded guilty.

With the help of a K-9 team, the robber’s scent was traced to “an area of bushes behind the bank surrounded by a small patch of grass, behind an adjacent building on Ocean Street,” court documents said. There, officers found a cellphone, a cigarette butt and an indentation in the grass that appeared to be the tracks of a bicycle leading away from the bank.

Police located Morrill at a friend’s house after tracing incoming calls to the phone found behind the bank, according to court documents. Investigators also found a text message on Morrill’s phone to the friend at whose home he was found that references Morrill’s having the gun and his plan to rob the bank.

Morrill faces 30 years in federal prison on the charge related to the Cumberland Farms robbery, up to 25 years in prison on the bank robbery charge, and up to 10 years in prison on the gun charge.

On the charge that Morrill used a firearm during the robberies, Morrill faces between seven years and life in prison. The sentence on that charge would be served following sentences imposed on the robberies.

Morrill also could be fined up to $250,000 and be ordered to pay restitution.