LAS VEGAS — Floyd Mayweather’s legacy is secure. The Las Vegas sportsbooks’ money is safe, too.

Despite UFC star Conor McGregor’s never-ending string of guarantees he would knock out the undefeated legend in his first-ever professional boxing match, Mayweather predictably maintained his perfect record after scoring a 10th-round TKO in the massively hyped non-title, junior middleweight bout, in front of 14,623 fans at T-Mobile Arena.

Returning to the ring for the first time in nearly two years, Mayweather (50-0, 27 KOs) surpassed Rocky Marciano’s revered 49-0 mark, and reportedly earned more than $200 million to fight the brash, and inexperienced, Irishman, who also collected a nine-figure payday, in an event expected to set revenue and viewership records.

Mayweather had won his previous seven bouts by decision, and hadn’t scored a knockout since beating Victor Ortiz in 2011.

“I guaranteed everybody this fight wouldn’t go the distance,” Mayweather said. “Boxing’s reputation was on the line.”

And no longer will Mayweather’s flawless record be on the line. The 40-year-old maintained his vow that he wouldn’t step in the ring again.

“This was my last fight,” Mayweather said. “I did walk away from the sport before. I didn’t have to come back. We do foolish things sometimes, but I’m not a damn fool. If I see an opportunity to make $300, $350 million in 36 minutes, I have to do it.

“But this is the last one. You have my word.”

McGregor (0-1), who is 21-3 with 18 knockouts in MMA, received an unprecedented percentage of backing as the betting underdog, and heavy fan favorite, putting the city’s sportsbooks in the precarious position of suffering their greatest financial loss ever on a sporting event, if one of the biggest upsets in history were to occur.

Of course, it didn’t. Of course, the house won. Of course, “Money” was a safe bet.

Initially, the southpaw’s unpredictable and unorthodox style appeared to present problems for the 12-time world champion, who threw few punches, while McGregor claimed the role of aggressor, landing uppercuts and hammer punches against one of the greatest defensive fighters in history.

“He was a hell of a fighter standing up,” Mayweather said. “He kind of shocked me.”

What was long treated as a farce became legitimately fun, and intriguing, as McGregor controlled the first three rounds.

Irish flags flew around the arena. Irish chants provided the soundtrack. The unimaginable was steering the night.

Then, logic counter-punched, with Mayweather finally hitting back in the fourth round. Suddenly, the strategy became clear.

The 29-year-old McGregor was showing fatigue, unaccustomed to boxing’s longer fights, which the 40-year-old Mayweather has perfected.

McGregor’s previous 10 fights had lasted an average of less than nine minutes. Mayweather had averaged more than 33 minutes in his previous 10 fights.

“Our game plan was to take our time, let him shoot his heavy shots early and then take him out down the stretch,” Mayweather said.

In the sixth, the crowd jumped to its feet for Mayweather for the first time, as he connected with multiple strong combinations, hinting at the ending to come. McGregor remained playfully defiant, responding by sticking out his tongue, eliciting chants of “Conor, Conor.”

Mayweather stayed uncharacteristically aggressive, leaving a dominant lasting image, while avoiding the letdown of his previous mega-fights. In the ninth, McGregor looked ready to go down twice, but held Mayweather, to remain standing.

“He’s composed, he’s not that fast, he’s not that powerful, but boy is he composed in there,” McGregor said. “I have to give it to him, that’s what 50 pro fights will do for you.”

In the 10th, referee Robert Byrd saw enough, stopping the fight at 1:05, with Mayweather pummeling an exhausted McGregor against the ropes.

It was the first time that McGregor — who repeatedly proclaimed to be the “king of boxing” and “God of boxing” before ever stepping through the ropes — lost while standing up, having suffered his only MMA defeats by submission.

“I thought it was a bit of an early stoppage. I was just a little fatigued,” McGregor said. “I wanted to keep going. I thought the ref should’ve let me keep going. Let me go down. Let the man put me down.

“I’ve been strangled on live TV and came back.”

Early Sunday, Mayweather was set to attend an afterparty at his strip club, where he had spent every early morning this week, leading up to a fight which had the potential to shatter a two-decade legacy in one evening.

There is always potential, though. Usually, predictability is victorious.

“I think we gave the fans what they wanted to see,” Mayweather said. “I owed them for the [Manny] Pacquiao fight. I had to come straight ahead and give the fans a show. I feel like I owed the fans for my last hurrah.

“I will always be remembered as a winner.”

Mayweather’s arms were raised once more, never to fall.