MEXICO CITY—Mexico is slipping toward a recession even as the U.S. economy continues to grow, the first time in 25 years that the neighbors’ economic cycles have fallen sharply out of sync.

The weakening economy is a new challenge for Mexican President Andrés Manuel López Obrador, following last week’s resignation of his finance minister, Carlos Urzúa, who abruptly quit and blamed the administration for putting political goals above economic considerations.

Mexico’s...