AUGUSTA — An Augusta man who spent six years in federal prison for armed robbery of a pharmacy in 2001 pleaded guilty today in Kennebec County Superior Court to charges that will send him back to jail for four years.

Zachary A. Gagnon, 32, admitted attacking a man with a hammer last summer in Augusta as well as having heroin on him when he was arrested on that charge Aug. 11 in Damariscotta Lake State Park.

Justice Michaela Murphy sentenced Gagnon to 10 years in prison, with all but four years’ suspended, and three years’ probation.

The sentence handed down today will run concurrent to three years Gagnon will be spending in federal prison.

On Monday afternoon in Bangor, U.S. District Court Judge George Z. Singal revoked the final 36 months of Gagnon’s supervised release. That supervised release was part of Gagnon’s 2002 sentence for armed robbery of a pharmacy, use of a firearm during the commission of a federal crime of violence and possession of Oxycontin with intent to distribute.

Gagnon was freed from federal prison in December 2008 after serving nearly six years of that eight-year sentence and began a five-year term of federal supervised release.

Gagnon was brought to state court in Augusta today to resolve the outstanding state charges.

He pleaded guilty to aggravated assault in connection with the June 26 hammer attack on Brett Gray as Gray was sitting with a woman at a picnic table at Carry-Out on Mount Vernon Avenue in Augusta.

Authorities at the time said the motive was robbery, and a charge of robbery related to the attack was dismissed in exchange for the plea to the other charges.

Gray was injured but did not incur any medical bills as a result of the attack, Assistant District Attorney Brad Grant told the Murphy. Grant said Gagnon’s identity was determined by tracing the vehicle’s registration plate and then showing a series of photos to the victim.

Gagnon also pleaded guilty to violating a condition of release that occurred that same day.

Gagnon also pleaded guilty today to a possession of heroin charge from Aug. 11 in Lincoln County and agreed to the forfeiture of $3,088 in cash he had on him at the time.

Assistant Attorney General Lisa Bogue told Murphy that authorities received a tip that Gagnon, who had both federal and state warrants out for his arrest, would be coming to the park.

They arrested him when he stepped out of the vehicle, and he had heroin, suboxone and the cash on him, she said.

Gagnon, who had his head shaved and wore a two-piece bright orange jail uniform, said little in court on Tuesday except to say “guilty” several times and to indicate he understood he was waiving rights to grand jury review of the charges as well as his trial rights,.

He consulted several times with his two defense attorneys, Thomas Dyhrberg, who represented him in both federal and state court, and William Baghdoyan, who represented Gagnon on several state charges.

Attorneys told Murphy that Gagnon will serve three years in federal prison followed by a year in state prison and then spend three years on probation.