(Adds analyst comments, background)
MEXICO CITY, June 5 (Reuters) - Mexico's peso gained on Monday to its strongest level in seven months after the ruling Institutional Revolutionary Party (PRI) fended off a leftist rival in a key state election, seen as a prelude to next year's presidential elections.
The peso appreciated by nearly 2 percent to 18.33 per dollar, it strongest since Nov. 9, the day after the surprise election of U.S. President Donald Trump, before retreating to around 18.42 per dollar.
The rally in the peso on the apparent setback for the National Regeneration Movement (MORENA) party of Andres Manuel Lopez Obrador signaled the market's distrust of the leader who has opposed economic liberalization in Mexico.
"MORENA's leader did not accept the result, but with the main event risk out of the way, the market is not going to wait for a final resolution. Unsurprisingly, the peso rallied on a PRI win," Citi Research said in a note to clients.
The election in the populous State of Mexico, where PRI candidate Alfredo del Mazo held a tight lead over MORENA's Delfina Gomez according to the latest results, is seen as a bellwether for Mexico's presidential elections in 2018.
Shares in OHL Mexico, the Mexican unit of Spanish construction firm OHL, rose by as much as 9.5 percent on the preliminary election results.
Lopez Obrador and other opposition leaders have accused OHL Mexico of helping to finance the PRI in the State of Mexico, allegations the company has rejected. (Reporting by Miguel Angel Gutierrez y Sheky Espejo; Writing by Anthony Esposito; Editing by Chizu Nomiyama and Meredith Mazzilli)