The feds saved Joseph “Big Joey” Massino’s life even before he turned rat.

The former Bonanno boss testified he would have been whacked if the FBI hadn’t arrested John Gotti in 1990.

Only years later did Massino learn that Gotti and Massino’s brother-in-law and protégé, Salvatore “Good Looking Sal” Vitale, had plotted to have him murdered as part of an effort by the Gambino kingpin to move in on the Bonannos. Under cross-examination at the murder trial of Massino’s successor, Vincent “Vinny Gorgeous” Basciano, Massino said that another mobster revealed the plan.

“He told me that they were going to make a move on me — they were going to kill me,” Massino testified. “If John was in the street, I believe him and my brother-in-law would have killed me.”

Vitale may not have killed Massino, but he delivered a near-fatal blow when he agreed to cooperate with investigators and testify at Massino’s murder trial. It was following that conviction on seven murders, and while still awaiting trial on an eighth, that Massino also agreed to turn stoolie.

As part of his cooperation agreement with the FBI, Massino agreed to turn over $7 million in cash and hundreds of gold bars.

But the Bonanno bad guy insisted yesterday that he had the kind of natural business talent that could have made him rich even without resorting to violence and intimidation.

“I didn’t need to be boss,” Massino said on the stand. “I didn’t need the life.” Basciano’s defense attorney, Richard Jasper, asked Massino if he believed that he could have been just as wealthy in a legitimate enterprise. “That’s fair to say,” Massino said.

“But you did make millions in the mob,” the defense attorney shot back.

“That’s correct,” Massino said of his Mafia fortune.

Massino, who wore a wire and managed to get Basciano to admit to ordering a hit on Bonanno associate Randy Pizzolo, showed a talent for drawing out dirt on his compatriot.

In order to get him to talk, he did have to stretch the truth a bit, he told defense attorneys, admitting that some of what he said on the tapes were outright lies.

“I just said that for conversation — I made that up,” Massino said. “I felt he was strokin’ me, so I was strokin’ him back.

You were bulls- – -tting me, so I’m bulls- – -tting you back,” Massino explained about his prison-house chats with Vinny.

He also used his undercover work as an opportunity to vent about the rigors of being a boss.