By Michael O'Boyle and Bruno Federowski

MEXICO CITY/SAO PAULO (Reuters) - Foreign investors in Latin America are warming to Brazil as a promising turnaround bet while souring on Mexico and its landmark energy reform that has yet to deliver.

Brazil has yet to recover from its worst recession in decades, inflation and interest rates remain among the highest in the region and it is saddled with a bloated public sector. In contrast, Mexico's economy is growing at around 2 percent, has lower fiscal deficits and sounder public finances.

But while Brazil interim president Michel Temer's reform agenda offers some promise, Mexico, once a darling of foreign investors, is now a source of disappointment. A slump in oil prices dashed hopes that President Enrique Pena Nieto's energy sector opening in 2013 along with telecoms and banking reforms would boost foreign investment and supercharge growth while clouds are now gathering over its budget and economy.

Out of 12 funds consulted by Reuters, seven have recently sold Mexico bonds and nine bought Brazil bonds. Five of the Brazil buyers were Mexico sellers. Five kept Mexico holdings steady, while three left Brazil exposure unchanged.

The funds ranked among the top investors in Mexico and Brazil according to Thomson Reuters eMaxx data.

Brazilian bond mutual funds saw net purchases and 16 percent returns in dollar terms through May, while Mexican debt funds lost 4.5 percent and saw redemptions, according to Lipper data. (Graphic: http://tmsnrt.rs/29o0WIe)

"Brazil offers a lot of turnaround potential," said Michael Ganske, head of emerging market fixed income at AXA Investment Managers, citing a return to more credible policies, inflation coming down and a potential for aggressive interest rate cuts.

Those who piled into Brazil early this year have already seen rich rewards while Mexican investors have been hammered by the peso's losses, which slashed dollar returns.

Brazil's stocks, bonds and currency are among the world's best performing assets this year, with the real number one among the world's 36-most traded currencies, up some 20 percent against the dollar.

Mexico's peso has been the second worst performing major emerging market currency this year behind the Argentine peso and it is trading near a record low despite aggressive interest rate hikes aimed at halting the slide. (Graphic:http://reut.rs/29hXzq5)

REVERSAL OF FORTUNES

A further reversal could bring a tectonic shift in investment flows. For example, more selling of peso bonds could further weaken the currency, which in turn could trigger stop-loss selling of more peso bonds.

The diverging fortunes of Latin America's top two economies in the past few years explain why now Brazil may look like a better deal.

While crippling recession, political turmoil and corruption scandals battered Brazilian markets, foreign holdings of Mexican stocks and bonds peaked in 2014. However, a sharp outflow from peso-denominated bonds in May raised concerns that a sell-off could be gaining pace.

"Brazil has had a very rough couple of years. The prices of assets are at rock bottom," said Bianca Taylor, head Latam debt analyst at Loomis, Sayles & Company, which until recently was the biggest holder of Mexican debt according to Thomson Reuters eMaxx data. She recommends cutting Mexico and adding Brazil.

Damien Buchet, co-chief investment officer at Finisterre Capital in London, has been among investors who have driven the biggest rally in Brazilian government bonds since 2012, having bought government debt early this year.

"Given the difference in valuation between the two stories, there are probably more opportunities to be disappointed in Mexico," Buchet said.

He said he also bought the bonds of scandal-plagued state-owned oil company Petroleo Brasileiro SA in February when its 2020 bonds traded at 75 cents on the dollar <71647NAH2=1M > and since have gained to around 93 cents. Now he is looking at debt of Brazilian chemical makers, beef processors, miners and steel producers.

Temer's pledges to cut spending and curb debt in a reversal of his leftist predecessor Dilma Rousseff's policies have lifted consumer and corporate sentiment.

A divided Congress remains a challenge, but with the Senate expected to confirm Rousseff's impeachment in August, giving Temer greater authority, fund managers see more room for gains.

Mexico, on the other hand, is at the beginning of what looks like a rough patch with growth far below the 6 percent rate Pena Nieto promised and its finances under growing pressure.

Government spending spiked on Pena Nieto's watch, but the oil slump hobbled income and Mexico's non-oil tax revenue is one of the lowest in the Americas. Things could get worse if Mexico fails to deliver promised budget cuts at state oil company Pemex.

Weak foreign direct investment also forces Mexico to rely on portfolio flows to finance its current account shortfall and exposes it to market swings. The possibility that Donald Trump, who advocates renegotiating trade and financial ties with Mexico, might win the U.S. presidency, could further boost peso volatility.

"You could have Mexico becoming much more at the center of the hurricane," said Benito Berber, an economist at Nomura in New York.

(Additional reporting by Sujata Rao in London, Nichola Saminather in Singapore and Jean Luis Arce and Alizeh Kohari in Mexico City; Editing by Christian Plumb and Tomasz Janowski)