MEXICO CITY—In 2006, Andrés Manuel López Obrador lost his first presidential race by a hair. He refused to concede, and in a surreal ceremony donned a presidential sash and declared himself Mexico’s legitimate president. Earlier, in a fiery speech in the capital’s historic square, he cursed Mexico’s governing institutions.

“Although my opponents may not like it, to hell with their institutions,” shouted the silver-haired politician as the crowd cheered wildly.

Now...