The Mafia put a contract out on “Tonight Show” host Johnny Carson after he drunkenly hit on a mobster’s mistress in Frank Sinatra’s favorite Manhattan bar, according to a new biography of the TV icon.

It was 1970, and a predictably sloshed Carson was pounding drinks at Jilly’s Saloon on West 52nd Street and Eighth Avenue at closing time.

“An attractive brunette at the bar caught Carson’s eye, and he was doing his considerable best to convince her to leave with him,” wrote Henry Bushkin in his new tome “Johnny Carson.”

But the beauty already had a beau — and he had a hair-trigger temper.

“And when her boyfriend — a major figure in the underworld — arrived, he was not grateful to Johnny for entertaining his ‘goomar’ in his absence,” Bushkin wrote.

The unidentified wiseguy and his goons picked Carson up off his bar stool and threw him down a flight of stairs before famed saloon owner Jilly Rizzo — whose regulars included Sinatra, Dean Martin and Judy Garland — interceded and prevented a more serious beatdown.

But the mob big wasn’t satisfied and put out a contract to have Carson whacked.

A terrified Carson wisely “holed up in his UN Plaza palace for three days, missing three shows,” according to the book.

The vengeful mobsters only backed off after one of Carson’s contacts at the William Morris Agency cut a deal with crime boss Joseph Colombo.

The mob boss had recently formed the Italian-American Civil Rights League to persuade America that people of Italian descent were being unfairly stereotyped as mafiosi.

The group was planning a big rally and “Colombo was deeply, deeply disappointed that so far all of the [TV] networks had refused to cover the rally,” Bushkin wrote.

“Soon an accommodation was reached. NBC News covered the rally, and Johnny could leave the apartment,” he wrote.

As for Colombo, he was gunned down in 1971 at the second annual Italian Unity Day rally in Columbus Circle. He was left almost totally paralyzed and died in 1978.

“That was the last of the rallies,” Bushkin noted.

Rizzo was a boyhood pal of Sinatra, who had his own chair permanently reserved in the back room of Rizzo’s watering hole, which drew as many mobsters as celebrities.