It’s unanimous: Mariano Rivera is a Hall of Famer.

The retired Yankees legend, considered by many to be the greatest closer of all time, became the first player to be voted into the Baseball Hall of Fame unanimously Tuesday, named on all 425 ballots submitted.

The career leader in saves — both during the regular season and playoffs — set yet another record as he headlined a class that includes Rivera’s former teammate Mike Mussina, as well as Edgar Martinez and Roy Halladay. They will join Harold Baines and Lee Smith, who were voted in by the Today’s Game Era committee last month.

Video posted by MLB on Twitter showed the normally unflappable Rivera celebrating excitedly in his home and being mobbed by his family when he was informed he received 100 percent of the vote.

On a conference call afterward, Rivera admitted he was shocked by the perfect vote.

“I wasn’t expecting to be a Hall of Famer when I was playing baseball,’’ Rivera said. “I was just happy to be in the big leagues and give the New York Yankees as many championships as I could. After my career, I was thinking I had a good shot to be a Hall of Famer [but] this is beyond my imagination.”

In the 75-year history of the Hall of Fame, no player achieved the perfection Rivera reached. The previous high was the 99.3 percent Ken Griffey Jr. received in 2016.

“To be considered a Hall of Famer is quite an honor,’’ Rivera said. “Being unanimous is amazing.”

Rivera, 49, spent his entire 19-year MLB career with the Yankees after signing with the organization for $2,500 out of his native Panama in 1990.

He was called up in 1995, when he struggled as a starter before showing glimpses of what was to come when he was moved to the bullpen.

Rivera went on to save 652 games in the regular season and 42 more in the playoffs in a career that was as dominant as it was consistent.

He helped the Yankees win five World Series title and was named World Series MVP in 1999, when they swept Atlanta and Rivera closed out three of the victories.

One of the only batters to have any success of Rivera and his cutter was Martinez, whose career 1.705 OPS versus Rivera is by far the best of any hitter who faced him more than six times. Martinez made it in his 10th and final year on the ballot.

“Going in with Mariano means a lot,’’ Martinez said. “Not only because he was the top reliever in the game and a great human being, but also the fact he got 100 percent of the votes makes it extra special.”

Mussina, in his sixth year on the ballot, made it in with 76.7 percent, just over the 75 percent threshold required. The right-hander spent eight years with the Yankees after 10 in Baltimore and said during a conference call he was unsure which hat he would wear into the Hall.

There was no drama for Rivera.

He was named an All-Star 13 times, including his final season in 2013, when Rivera returned from the freak knee injury that cost him most of 2012 and finished his career in superb fashion.

Now, he will join the ranks in Cooperstown when he’s inducted at the ceremony in July, the first of the Core Four to be enshrined, with Derek Jeter certainly to follow next year.

Whether Jeter has company remains to be seen, as Roger Clemens and Barry Bonds, both tainted by performance-enhancing drug scandals, hover around 60 percent. Fred McGriff came up short again and will be off the ballot next year after a decade, while Andy Pettitte will stay on after getting 9.9 percent.

“I hope, definitely, Derek will be there next year,’’ Rivera said. “Andy and Jorge [Posada], to me that would be the greatest moment of my life, knowing those guys would be there, too.”

No doubt Tuesday will be on that list, as well.