With the victory, Aldo remained the only champion the division has known and extended his winning streak to 15, one short of Anderson Silva's record of 16 straight victories from 2006 to 2012.
The highly anticipated mixed martial arts fight was a rematch of their encounter in Rio de Janeiro in 2012. Aldo knocked out Mendes with a powerful knee strike to his face with a second left in the first round of that match.
Mendes extended the fight to the fifth round this time but still couldn't come up with the victory. All three judges scored it 49-46.
"I deserved to win," Aldo said. "He hit me a few times but I hit him a lot more. It was a great a fight and I'm sure everyone enjoyed it."
It was the seventh straight successful title defence for the 28-year-old Aldo (25-1), who is unbeaten since 2005. He was under extra pressure as the only Brazilian to hold a belt among all UFC weight divisions. It could have been the first time in eight years that Brazil was without a champion.
The 29-year-old Mendes (16-2) had been dominant since his lone career defeat two years ago in Rio, winning four of his next five fights by knockout.
He was aggressive from the start this time, connecting early with kicks and punches and opening a wound on Aldo's nose. But the Brazilian recovered fast and finished strong in the first round, twice knocking Mendes down with powerful strikes.
"He rang my bell for sure," Mendes said. "I was just going so hard I didn't know what was going on. I was just trying to push myself and obviously just outstrike him and mix things up well."
Both fighters took fewer chances in the second round. Aldo made a strong charge near the end of the round but couldn't finalize his opponent.
Mendes tried to take the initiative more often in the final two rounds but did not have enough to turn things his way. Aldo finished with a heavily swollen left eye.
In the co-main, American Phil Davis (13-2), a former NCAA wrestling national champion, beat Brazilian Glover Teixeira (22-4) by unanimous decision to earn his first shot at challenging light heavyweight champion Jon Jones. Teixeira lost to Jones in his previous fight.
In other main card fights, Beneil Dariush of Iran beat Brazilian Diego Ferreira in a unanimous decision in the lightweight division, and Darren Elkins of the United States edged Brazilian Lucas Martins with a split decision in the featherweight division.
Brazilian Fabio Maldonado got past Hans Stringer of the Netherlands with a technical knockout in the second round in a light heavyweight matchup, celebrating by hugging Silva atop the octagon.
In a preliminary fight, American welterweight Neil Magny beat Brazilian William Patolino by technical knockout in the third round to win for the fifth time in a row this year and tie Roger Huerta's modern-era record for most UFC victories in a single calendar year.