The real estate developer charged with leaving his pal to die after drunkenly crashing his Porsche in Sag Harbor took a plea deal Tuesday in a ​Long Island courtroom — and finally apologized to the family​ of his victim.

Sean Ludwick, 44, pleaded guilty in exchange for three to nine years in prison, said the Suffolk County district attorney in a statement.

“I’d just like to say I’m very sorry — I feel awful for the circumstances,” Ludwick told victim Paul Hansen’s family in court in Central Islip​, according to 27East.com.

“I want to extend my deepest sympathies and remorse … particularly to Austin and Hunter,” he said, referring to the victim’s sons, the local news site reported.

The Sag Harbor real estate agent was a passenger in Ludwick’s Porsche on Aug​. 30, 2015.

Ludwick had a blood-alcohol level of .18 — more than twice the legal driving limit — when he slammed his Porsche into a utility pole outside Hansen’s home on Rolling Hill Court East.

Ludwick dragged his pal out of the car and left him for dead, then took off in the damaged vehicle, officials said.

The despised developer was initially free on $1 million bond, but it was revoked after prosecutors said he plotted an escape to South America.

He copped to aggravated vehicular homicide, leaving the scene of a fatal crash and aggravated driving while intoxicated.

“It was a tragic case for all concerned,” said his def​​ense lawyer, Dan Ollen. “Our hearts go out to Mr. Hansen’s family.”

He added, “Sean spoke from the heart when he told the family how sorry he was.”

Ludwick is due back in court Oct. 18 for sentencing.