Mayweather, 43-0, was guaranteed $32 million. Cotto, who fell to 37-3, was guaranteed his biggest purse ever, $8 million.
Mayweather dominated late, rocking Cotto in the 12th round to pull out a win and remain unbeaten in 43 fights.
Unlike most of his fights, though, Mayweather got his nose bloodied and engaged in some bruising exchanges he usually likes to avoid.
Two judges scored the fight 117-111 and the third had it 118-110. The Associated Press had Mayweather winning, 116-112.
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, 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. Cotto was never down, though he seemed hurt several times.
The win gave Mayweather the title held by Cotto and assured him of being a champion when he reports to jail June 1 for a sentence stemming from a domestic abuse case involving his former girlfriend and their children.
Mayweather will be in jail when Manny Pacquiao fights in the same ring June 9 at the MGM Grand against Timothy Bradley. Though boxing fans have clamored for a Mayweather-Pacquiao fight, it has yet to be made - and may never be made.
That's partly because of Mayweather's insistence that Pacquiao submit to drug testing, though Pacquiao has already said he will do that.