Alves, regarded by many as the most successful player in history, had rejoined Barca in November but confirmed last month that he would not be extending his contract.
“I’m like an excited 15-year-old who leaves home to go fight and write a beautiful chapter in his story,” the 39-year-old wrote on Instagram before arriving in Mexico City.
Alves signed before the cameras after a medical that Pumas president Leopoldo Silva said had gone “very well”.
He joins Argentine attackers Gustavo del Prete and Eduardo Salvio who have also joined the seven-time Liga MX champions.
Alves made 408 appearances in total for Barcelona, with 391 of those coming in his first spell from 2008-2016.
During that initial stint, he won six La Liga titles, three Champions League crowns and four Copa del Rey trophies.