Mayweather dominated late, rocking Cotto in the 12th round to pull out a win and remain unbeaten in 43 fights. But it wasn't easy, with Mayweather getting his nose bloodied and Cotto fighting until the final bell.
Two judges scored the fight 117-111 and the third had it 118-110. The Associated Press had Mayweather winning 116-112.
"You're a hell of a champion," Mayweather told Cotto in the ring afterward. "You're the toughest guy I ever fought."
Fighting just a few weeks before he enters a county jail to serve a three-month sentence for domestic abuse, Mayweather found himself in a tough fight against a game opponent who never stopped moving forward. But he was faster and more accurate than Cotto and seemed to wear him down in the final rounds.
In the last round, Mayweather landed his best punch of the night, a left uppercut that seemed to hurt Cotto. He followed that with several flurries to the head to wrap up a decision that until the later rounds had been in doubt.
The decision was roundly booed by the crowd at the MGM Grand arena, which cheered wildly every time Cotto landed a punch.
"He's a tough competitor," Mayweather said. "He came to fight, he didn't just come to survive. I dug down and fought him back."
Mayweather, who was guaranteed $32 million, was forced to fight every minute of all 12 rounds against the Puerto Rican champion. He did it after weighing in at 151 pounds, the heaviest he has ever been for a fight.
The weight didn't seem to affect Mayweather, and neither did the heavier 10-ounce gloves at super welterweight. But he took some punishment before coming back to dish some out in the later rounds.
"When you fight on pay-per-view you have to give the fans what they want, and that's excitement," Mayweather said.
Cotto came out looking slow and overmatched in the first round, but quickly settled into a routine, attacking Mayweather from behind his left jab. But Mayweather got more aggressive coming out to start the fourth round, and landed a series of rights to the head that stunned Cotto and kept him from moving forward effectively.
Mayweather fought good portions of the fight on the ropes, using them for leverage and counterpunching to Cotto's head when he opened up. He was not only quicker than Cotto, but more accurate, often landing in between Cotto's defenses.
"He's ready to quit," trainer Roger Mayweather told his nephew after the sixth round.
But Cotto was relentless, coming forward and hitting Mayweather with good shots to the head. Toward the end of the eighth round he landed several punches to the head, prompting Mayweather to shake his head as if they didn't hurt, but by then Mayweather was bleeding from the nose and looked like he had taken some punishment.
Punch stats showed Mayweather landing 179 of 687 punches to 105 of 506 to Cotto.
Cotto, who fell to 37-3, was guaranteed his biggest purse ever, $8 million.