Lopez Obrador, 67, said he was receiving medical treatment and his symptoms are mild.
"As always, I am optimistic," he tweeted.
Lamento informarles que estoy contagiado de COVID-19. Los síntomas son leves pero ya estoy en tratamiento médico. Como siempre, soy optimista. Saldremos adelante todos. Me representará la Dra. Olga Sánchez Cordero en las mañaneras para informar como lo hacemos todos los días.
— Andrés Manuel (@lopezobrador_) January 25, 2021
Lopez Obrador took office as president in December 2018.
He is among a number of world leaders who have contracted the virus during the pandemic. Most have since recovered. Among them: Boris Johnson of Great Britain, Emmanuel Macron of France, Jair Bolsonaro of Brazil, and former U.S. President Donald Trump.
Ambrose Mandvoul Diamini, the prime minister of Eswatini - the southern Africa nation also known as Swaziland - died in December 2020 about a month after a positive test for COVID-19.
The Associated Press contributed to this report.