MEXICO CITY, June 19 (Reuters) - Investors who have been holding their ground in Mexico could lose their nerve if leftists take control of the country’s Congress in next month’s election or U.S. President Donald Trump ditches talks to overhaul the NAFTA free trade deal.

Mexico’s peso has held up better than emerging market peers including Argentina, Turkey and Brazil amid a global sell-off since April as higher U.S. borrowing costs sapped the appeal of riskier assets.

Even so, it is down 12 percent since mid-April, hit by the triple threat of a dollar rally, fears that the United States, Mexico and Canada could fail to rework the North American Free Trade Agreement and worries about the July 1 election.

Analysts polled by Reuters early in June were counting on a rebound in the peso by the end of the year, but those hopes could be dashed if leftist front-runner Andres Manuel Lopez Obrador wins the presidency, gains a congressional majority and signals a move toward more radical economic changes than many have been expecting.

Lopez Obrador has held a double-digit lead in most polls since early this year. While many foreign investors have become resigned to a win by the left, most have not counted on a major shift in economic policy, according to a May poll by Nomura.

Investors interviewed by Reuters warned the peso could lose further ground if Lopez Obrador’s National Regeneration Movement (MORENA) party gains a majority in Congress, which would remove checks on ramping up spending and could herald more radical policy changes.

“If he sweeps Congress, it will be ugly,” said Richard Hall, an emerging market debt and currency analyst at asset manager T. Rowe Price.

A study by polling firm Mitofsky in late May projected MORENA and its allies could win majorities in both houses, while a poll published in June showed it would fall a few seats short.

A majority in both the lower house and the Senate could mean Lopez Obrador would not have to work with the country’s current ruling, centrist party or the main conservative opposition to pass a budget.

The former Mexico City mayor, known as AMLO, has eased some investors fears by pledging to keep government spending in line with current levels, back the free-floating peso and work toward a NAFTA deal.

However, his statements that he could halt an opening of the energy sector to private investment or ramp up government subsidies on gasoline and food still have many worried.

“We hope that we don’t hear huge amounts of un-market-friendly comments after the election,” said Andrew Stanners, an emerging markets bond fund manager at Aberdeen Asset Management in London. “If he is sensible, then reasonable people will come back, and it should be fine.”

But until investors see what sorts of messages Lopez Obrador sends out following a win, “the market will be on tenterhooks,” he said.

Even if Lopez Obrador calms worries about a dramatic economic shift, a post election rally could be muted by worries about the future of NAFTA, which Trump has repeatedly threatened to scuttle if it is not reworked to benefit U.S. workers.

Conrad Saldanha, a portfolio manager at the Neuberger Berman Emerging Markets Equity Fund, said the risk of a NAFTA collapse was “the bigger concern for Mexico” compared to the election.

“Mexico has good underlying fundamentals in terms of demographic and consumer trends, however there is this albatross of NAFTA,” he said.

Aberdeen’s Stanners said the peso would sink past 22 per dollar compared with current levels of around 20.50 if Trump pulled out of the treaty. But he saw room for the currency to head back toward 17 per dollar if a Lopez Obrador government is moderate and there is a successful NAFTA renegotiation.

Paul Greer, an emerging market debt and currency portfolio manager at Fidelity International, said he expected there would be a NAFTA deal during next year.

“Once we get more into the new AMLO reality people will be more relaxed,” he said. (Reporting by Michael O’Boyle, Stefanie Eschenbacher and Sheky Espejo; Editing by Christian Plumb and Tom Brown)