John Gotti, the namesake grandson of the late Gambino crime family boss, has been slapped with five years in federal prison.

The 24-year-old was sentenced Wednesday in connection with his role in the 2012 revenge arson of a car whose driver had cut off longtime Bonanno big Vincent Asaro on a Queens road.

A well-groomed and cheerful-looking Gotti apologized to both his family and the court before Brooklyn federal Judge Allyne Ross handed down her sentence.

The tatted-up mafia scion’s words brought his father, Peter Gotti, to tears. The courtroom’s pews were packed with his relatives, including the widow of the Teflon Don, Victoria. She was accompanied by her son, John “Junior” Gotti.

“I just want to say I’m sorry to my family first and foremost,” Gotti said from the defense table, looking into the gallery at his gaggle of family and friends. “My actions were selfish. I apologize to the courts, it’s a waste of taxpayer dollars.”

“I’m in a good place today,” added Gotti, who’s been open about his struggle with opioid addiction. “I look forward to the years to come. I know when I leave here I can give back to the world.”

Defense attorney Charles Carnisi asked Ross to show his client leniency, saying that, at the time of the torching, Gotti was “a dopey 18-year-old kid who allowed himself because of other factors to become involved” in the arson.

Yet federal prosecutor Keith Edelman noted that Goti, at the times of the torching and a burglary he admitted to committing a mere two weeks later, had yet to spiral into addiction.

“He was doing this to ingratiate himself with a well-known criminal,” the assistant US attorney said.

Ross called the charges “unquestionably serious” before sentencing him, and agreed with the government that he’d partaken in the arson “out of allegiance to a violent Cosa Nostra associate.”

Both Ross and Edelman were referring to known Bonanno capo Vincent Asaro.

Despite his stunning acquittal after being accused in the 1978 “Goodfellas” Lufthansa heist, the 82-year-old was finally nailed last year on the arson charges. Ross, who oversaw the 2015 Lufthansa trial, sentenced him to eight years behind bars in December after he admitted to ordering the vehicular hit.

In addition to prison time, Ross ruled that Gotti would have to cough up some $27,000 in restitution — for the cost of the car — and would be subject to a curfew when he was released.

Gotti is already serving an eight-year state sentence after copping to possessing narcotics with the intent to sell. Ross ordered that two and a half years of his five-year federal sentence be served at the same time as the drug sentence.

The other 2.5 years behind bars will be tacked onto the end of his 8-year-sentence, she said.

He was also instructed, following his release, to take part in a drug-treatment program.

Gotti, who thanked Ross following sentencing, blew a kiss to his family as he walked uncuffed into the pens.

Outside court, “Junior” Gotti commended his nephew for “taking responsibility for his actions.”

Victoria Gotti opened her mouth to speak but was overcome by tears.

Junior interjected, saying , “My mother’s heartbroken,” before gently taking her arm and leading her away.

Junior earned the nickname Teflon Don Jr. after he was acquitted of racketeering charges at four separate trials before he was finally nabbed — and pleaded guilty — to reduced charges of loansharking, bookmaking​ and ​extortion. He was released from prison in 2009.

Junior’s father, the original Teflon Don, evaded conviction for years, until he was​ finally convicted in 1992 on charges of murder, conspiracy to commit murder, racketeering, obstruction of justice, illegal gambling, extortion and other charges.

He was sentenced to life behind bars but served only 10 years before dying of cancer in 2002.