A man accused of murdering a friend at a 2014 Freeport party after firing a gun into a crowd pleaded guilty to manslaughter Monday, according to authorities.

A judge said he would sentence Autrey Smith, 23, of Roosevelt, to 25 years in prison under the terms of the plea deal, according to Smith’s attorney, Brian Carmody.

Carmody had argued at Smith’s arraignment last year that his client wasn’t legally responsible for the death of Lyreek Crawley, 21, of Freeport, because Smith became “involuntarily intoxicated” after someone drugged Smith’s drink at the house party.

The Westbury attorney said Tuesday that Smith was “sorry for the death of his friend.”

“He didn’t want the victim’s family to go through a trial,” Carmody said of the guilty plea.

Authorities said Smith opened fire several times with a gun during the party and Crawley died at the scene after suffering a gunshot to his head in the backyard of the Freeport home on Dec. 28, 2014.

advertisement | advertise on newsday

Prosecutors said Smith fled the scene and went to an out-of-state location for three days before returning to New York and surrendering to police.

Smith had been facing the possibility of a sentence of 25 years to life in prison if he had been convicted of murder.

Jury selection was underway for Smith’s trial on charges that included murder, attempted murder, manslaughter and weapon offenses when he decided to plead guilty, his attorney said.

Nassau District Attorney Madeline Singas said in a prepared statement Tuesday she hoped Smith’s plea “will help Lyreek Crawley’s loved ones heal from this horrible loss.”

The judge set sentencing for Oct. 27.