BRASILIA/SAO PAULO - The Brazilian currency's monster rally may soon run out of gas, analysts and government officials say, as U.S. interest rate hikes and risks to the Chinese economy threaten the fundamentals of the world's best-performing major currency.

Brazil's real has gained over 18% against the U.S. dollar so far this year, more than twice the rise of any other peer, as aggressive rate hikes drew in foreign investment flows seeking distance from the Ukraine war.

While Brazil's double-digit interest rates may still offer a lucrative carry trade for hot money, looming rate hikes from the U.S. Federal Reserve may narrow that gap quickly. China's aggressive lockdowns to fight COVID-19 have also weighed on prices for the iron ore, soybeans and oil that Brazil exports.

"There are two big risks to the real's performance: the Fed raising rates more than expected and a sharp deceleration in the Chinese economy that could affect commodity prices," said Alvaro Mollica, emerging markets strategist for Citigroup.

A note from his colleagues at Citi Economics on Thursday flagged "a weaker currency ahead" for Brazil, forecasting a year-end exchange rate of 5.19 reais per dollar – a nearly 10% depreciation from Wednesday's close.

Even in Brazil's Economy Ministry, which has trumpeted the jump in foreign investment and perks of a stronger currency for fighting inflation, some officials doubt the trend will continue indefinitely. Right-wing President Jair Bolsonaro's government, which generated huge initial optimism among investors, has had a mixed record on reforms as well as privatizing state assets.

"I haven't seen any structural factor, unfortunately. It all seems circumstantial," said one official, requesting anonymity to give a frank assessment of the market. "The dollar came way down, even below where some institutions see its equilibrium ... I think there's room for some reversal."

The same official pointed out that Brazil's main stock exchange, which has attracted a net 69 billion reais ($14.7 billion) in foreign flows this year, no longer looks so cheap in dollars or reais after an 11% runup this year.

Another ministry source agreed that, apart from Brazil's interest rates, the major drivers of the currency rally have been "external" and are subject to change.

Not all officials are so skeptical.

Fausto Vieira, undersecretary of macroeconomic policy at the Economy Ministry, said business-friendly regulation is boosting investment in areas such as sanitation, where private capital spending has jumped from 3 billion to 30 billion reais annually.

The ministry projects some 360 billion reais in new private investments through 2025, helping to draw long-term foreign capital flows regardless of short-term market effects.

However, that may hinge on this year's election. Leftist former President Luiz Inacio Lula da Silva, who leads Bolsonaro in polling ahead of the October vote, has vowed to roll back much of the incumbent's economic agenda.

As the presidential race heats up, analysts warn that both Lula and Bolsonaro may resort to more populist rhetoric, raising investor concern about the country's fiscal discipline.

For now, Brazil's risk premiums have come down, noted economist Jonathan Petersen of Capital Economics, which "may reflect fading concerns about fiscal sustainability and political risks."

"But if our outlook for falling commodity prices and weakening economic growth proves correct, these concerns may re-emerge, especially prior to the election," he told clients in a Thursday note, forecasting the exchange rate at 5.0 reais per dollar by the end of the year.

(Reporting by Marcela Ayres in Brasilia and Tatiana Bautzer in Sao Paulo Writing by Brad Haynes Editing by Chizu Nomiyama)