It was time for Tommy ­DeSimone to die.

The mobster — famously portrayed by Joe Pesci in “Goodfellas” — killed two made men, tried to rape the wife of his gangster pal Henry Hill and stupidly lifted his ski mask during 1978’s historic $6 million Lufthansa heist.

So John Gotti took care of it — personally.

The handsome capo used a silencer-equipped Colt .38 to shoot DeSimone three times in the skull in January 1979 in the basement of an Italian restaurant on Arthur Avenue in The Bronx, says an upcoming book, “The Lufthansa Heist,” written by Hill and journalist Daniel Simone.

It’s the first time the details of Gotti’s role in the death of the 28-year-old psychopath have been revealed.

Hill heard the specifics surrounding DeSimone’s murder from Sal Polisi, a Gotti confidant he met in the Witness Protection Program. When Hill collaborated with author Nicholas Pileggi on “Wiseguy,” the 1986 book that was the basis of “Goodfellas,” he withheld the information on De­Simone’s slaying because he feared reprisals from Gotti, who by then had risen to become godfather of the Gambino crime family.

The book by Hill and Simone, due out Aug. 1, also exposes Gotti’s part in the infamous Dec. 11, 1978, holdup of the Lufthansa freight terminal at JFK Airport, the biggest heist in US history at the time. The robbers made off with about $5 million in cash and $1 million in jewelry, none of which was ever recovered.

The theft was planned and orchestrated by Hill and Jimmy “The Gent” Burke, both underlings of Lucchese underboss Paul “Paulie” Vario. In “Goodfellas,” Hill was played by Ray Liotta, Burke by Robert De Niro, and Vario by Paul Sorvino.

The heist

The robbery was set up by the Luccheses, while Gotti was a captain in the Gambino family, but the airport was turf shared among the crime families, so Gotti, then a captain in the Gambino family, needed to be cut in. The book reveals that Gotti got a $200,000 cut of the proceeds.

Gotti, Burke and Hill discussed the caper beforehand at Prudenti’s Vicin’ O Mare, an Italian restaurant in Long Island City, Queens.

“It’s a good shot. I like it,” Gotti said. “What can I do to make it go smooth?”

“Well, John, we need some cooperation,” Burke said.

Gotti promised to provide a warehouse where the loot hauled from Lufthansa could be transferred from the getaway van into a “switch car” to evade the cops. He also offered to destroy the getaway van at an auto salvage yard he controlled in Brooklyn.

A notoriously bad gambler, Gotti blew his share of the loot at the Aqueduct Racetrack, author Simone says. He kept quiet about his role in the heist because he didn’t share his cut with his Gambino bosses.

When they carried out the heist, DeSimone and his fellow robbers wore ski masks so the night-shift workers they rounded up at gunpoint in the Lufthansa warehouse lunchroom wouldn’t identify them to police. But De­Simone raised his mask to wipe sweat from his cheeks, and someone saw enough to help a police artist sketch his face.

This infuriated Burke and Vario, but they needed De­Simone’s skills as a killer. They wanted to eliminate any ­participant in the robbery who could finger them to the cops or the FBI.

The first to die was Parnell “Stacks” Edwards, who after the robbery was to have delivered the getaway van to be crushed at the Gotti-run salvage yard. Instead, Edwards parked the van by a fire hydrant in Canarsie, Brooklyn, where cops found it two days later.

Vario ordered DeSimone to kill Edwards. “Stacks gotta go . . . He’ll give up every one of us,” Vario said.

“Paulie, how can you ask me to whack Stacks?” DeSimone pleaded. “I mean, him and me go back before I can remember. I’m the only person on earth he trusts.”

Vario vowed that in return for killing Edwards, DeSimone would get his “button” — he would become a made man, an official member of the mob.

“I promise you I’ll do whatever I can to make it happen,” he said.

DeSimone went to Edwards’ hideout and put five bullets in his skull.

“Sorry, pal. I hope it didn’t hurt. Sooner or later, I’ll see you in heaven or hell. Wherever you’re going, I’m sure that’s where I’ll be going,” he said.

The request

DeSimone soon joined him.

For years, the Gambinos had simmered over DeSimone’s unsanctioned murders of two of their own mobsters, William “Billy Batts” Devino and Ronald “Foxy” Jerothe.

Devino — a made man whose last name is sometimes given as Bentvena — spent several years in federal prison on drug charges. During that time, DeSimone and Burke took over his loanshark business. They wanted to keep it, so after Devino was released, DeSimone and Burke killed him, says author Simone.

In “Goodfellas,” DeSimone kills Devino over an insult about his past as a shoeshine boy. That part of the movie was fiction, Simone says.

Jerothe died because he punched DeSimone in the face in a feud over Jerothe’s sister, whom DeSimone was dating, mob lore says.

When Gotti, still seven years from becoming the “Dapper Don,” heard DeSimone was about to be “made,” he demanded a sit-down with Vario.

“This f- -kin’ DeSimone whacked two of my top earners, and I let it go for a long time,” Gotti told his fellow capo. “Now he wants to be made, and I’m not gonna sit quietly. I mean, that’s as bad as putting a cactus up my a–. Understan’ what I’m sayin’, ­Paulie?”

“John, what do you suppose I should do?” Vario asked.

“Paulie, all I want is what’s fair,” Gotti said. “I wanna whack the bastard, and I want you to give me the green light.”

Vario considered how DeSimone was a constant source of agita. He also figured the feds or the cops would soon pinch DeSimone for the robbery. But there was another reason, the book ­reveals.

When Hill was in federal prison several years before, DeSimone had tried to assault Hill’s wife, Karen. Vario was furious about this — partly because, at the time, he and Karen were having an affair.

Thus Gotti’s request to kill DeSimone “was timely and well received,” the book says.

Gotti knew of Burke’s involvement in Devino’s slaying. But Burke was an “extrordinary” earner on Vario’s crew and thus had Vario’s protection, Simone says. Vario would not let Gotti kill him.

The hit

The night DeSimone expected to be inducted into the mob, Vario’s son drove him from his home in Ozone Park, Queens, to Belmont in The Bronx. DeSimone wore “a double-breasted black Bill Blass suit, a starched blue shirt and beige silk tie,” the book says.

DeSimone was led to the basement of Don Vito’s restaurant. Several old men were seated around a card table, and candles gave the room a dim light. De­Simone was surprised to see Gotti, a Gambino. He thought his induction would be a Lucchese affair.

“Welcome, Tommy. Congratulations!” Gotti said. “Pull a chair up to the table and sit comfortably. This is not an ordinary day in your life, I want you to know.”

DeSimone sat down. Within three seconds, “Gotti pulled out a silencer-equipped .38 Colt Magnum from his inner breast pocket and drilled three bullets into DeSimone’s cranium. PAH . . . PAH . . . PAH.

“DeSimone’s head blasted forward, and with the thud of a ­10-pound boulder slumped onto the card table, blood seeping and leaching onto the green felt ­tabletop.

“Gotti buttoned his camel cashmere overcoat, straightened the lapels and walked out of the room with a vaunting stride,” the book says.

DeSimone’s remains were never found.

Vincent Asaro, a 78-year-old alleged Bonanno mobster, goes on trial this fall on numerous charges, including allegations he helped plan the Lufthansa robbery. The feds say their charges are backed up by four witnesses. But Simone says his sources insist Asaro was not involved in the crime.

Vario died in 1988, Burke in 1996, Gotti in 2002, and Hill in 2012. Before his death, Hill told Simone that no one involved in the heist was still alive.