22 June 2018, Russia, Saint Petersburg, Soccer, Group E, Matchday 2 of 3, Brazil vs Costa Rica at the St. Petersburg Stadium: Fans of Brazil celebrate on the stands.

Emerging market stocks were on fire last month and Brazil was the biggest beneficiary of that rally.

The iShares MSCI Brazil exchange-traded fund (EWZ) surged 12.6 percent in July, posting its first positive month since January, when it gained 15.2 percent. Brazil's Bovespa index, meanwhile, jumped 8.9 percent last month.

Brazil's strong gains come as the iShares MSCI Emerging Markets ETF (EEM) rose 3.5 percent last month. The index posted its first monthly gain since March, when it went up 0.5 percent. It also recorded its biggest monthly jump since January, when it surged 8.3 percent.

"There is an improvement in risk sentiment across emerging markets and Brazil is piggybacking off of that," said Peter Donisanu, investment strategy analyst at Wells Fargo Investment Institute. Donisanu noted that recent easing of trade tensions between the U.S. and some of its key partners improved sentiment around emerging markets and Brazil.

Last week, President Donald Trump said the U.S. and the European Union would work together to lower tariffs on industrial goods. "We agreed today, first of all, to work together towards zero tariffs, zero non-tariff barriers and zero subsidies for the non-auto industrial goods," Trump said on July 25.

Trump's comments came after the United States slapped tariffs on steel and aluminum imports from the European Union, to which the EU retaliated.

The U.S. and China are also reportedly seeking to restart talks in order to avoid a trade war. Bloomberg News reported, citing sources, that representatives of Treasury Secretary Steven Mnuchin and Chinese Vice Premier Liu He are talking privately to resume the discussions. The U.S. has already imposed tariffs on $34 billion in Chinese imports, which were met with retaliatory charges by China.

Most emerging markets are primarily export-based economies, meaning that increasing trade barriers directly impact their ability to grow economically. Brazil, for example, was the 24th-largest exporter in the world back in 2016. That year, Latin America's biggest economy exported $191 billion in goods.

The EWZ fund was down 20.8 percent for the year entering July as investors booked profits from the strong performance in Brazilian stocks last year and worries about tariffs rattled investors, said Donisanu of Wells Fargo.

"In the early part of the year, the weakness was a reflection of the strong EM performance last year," he said. "After a strong year, you had investors evaluate the fundamentals. … Coming into the second quarter, you had the start of tariffs. But recently, the broad trade narrative has improved."

Larry McDonald, head of the U.S. macro strategies at ACG Analytics and editor of The Bear Traps Report, said Brazil's impressive performance should continue as the U.S. Federal Reserve may have to conclude its balance-sheet unwinding sooner than expected. The Fed grew its portfolio — also known as the balance sheet — to $4.5 trillion as a way to stimulate the economy during and after the financial crisis.

"They originally made a plan on the balance sheet to reduce it by $50 billion a month starting in September," McDonald said. "But now they've opened the door … to softening the policy path."

Boston Fed President Eric Rosengren told the Wall Street Journal in late June that the balance sheet, could be putting "more upward pressure on short-term interest rates that we anticipated," meaning the central bank may have to keep its portfolio size closer to historical highs.

Emerging markets are highly sensitive to changes in U.S. monetary policy. Tighter monetary policy usually leads to higher rates and a stronger dollar, both of which can negatively impact emerging-market exports to the U.S.

"Right now, you want to be in EM and Brazil should be part of that story," McDonald said.

But even with last month's rally, Wells Fargo's Donisanu said he is not calling an "all clear" on Brazilian stocks, noting there are still facing risks, including an escalation in trade fears.