A homeless man who crushed his friend’s skull with a chunk of concrete two years ago after they slept outside a church in Patchogue was sentenced Friday to 25 years in prison.

Thomas Lamartina, 33, pleaded guilty Aug. 31 in Riverhead to first-degree manslaughter in the June 28, 2014, killing of Nicholas MacQueen, 65, who was also homeless.

In return for the plea, State Supreme Court Justice William Condon had agreed to sentence Lamartina to the maximum of 25 years in prison. Condon handed down that sentence Friday, according to Suffolk County prosecutors.

“He has always said he didn’t intend to kill him,” defense attorney Craig McElwee of Hauppauge said when his client agreed to the manslaughter plea deal.

The attack happened outside Emanuel Lutheran Church, on East Main Street, where the men hoped to get a free breakfast in the morning.

“They had both passed out on the steps of the church,” McElwee said. “When he woke up, he was being improperly touched and temporarily lost his mind.”

advertisement | advertise on newsday

Lamartina told a similar story to homicide detectives when he was questioned, saying he was responding to an unwanted sexual advance.

Assistant District Attorney Kathleen Kearon said she didn’t believe such a thing happened. It was more likely, she said, that Lamartina killed MacQueen during a drunken rage, which he sometimes had.