Jair Bolsonaro's repeated bashing of China on the campaign trail last year left diplomats on both sides worried he might take a wrecking ball to one of the world's biggest trading partnerships.
But 11 months into Bolsonaro's presidency, the visit this week of his Chinese counterpart, Xi Jinping, for the BRICS summit looks set to complete a repair of the relationship.
Presidents of the group of major emerging economies - Brazil, Russia, India, China and South Africa - will meet in Brazil's capital on Wednesday and Thursday for what are widely expected to be low-key, technical discussions.
The five leaders will focus on stimulating investment in their countries amid a slowing world economy, while patching up disagreements on issues such as Venezuela and Bolivia, diplomats said.
Before the summit, Xi and Bolsonaro will hold bilateral meetings on Wednesday morning.
"It's going to be the endpoint of a process of making up after what was the worst crisis of the relationship between Brazil and China of the past decades," said Oliver Stuenkel, an international relations professor at the Getulio Vargas Foundation, a Brazilian university.
China will likely seek to signal that it is an "all-weather friend" to Brazil, Stuenkel said.
China, which is Brazil's largest trading partner with $98.7 billion in two-way trade last year, buys vast quantities of commodities from South America's largest country. Chinese demand has surged for soy and other farm products amid China's trade war with the United States.
In the lead-up to the last year's election, things looked very different. "The Chinese are not buying in Brazil. They are buying Brazil," Bolsonaro said on repeated occasions.
But the far-right former army captain has struck a more conciliatory tone since taking power. There have been high-level meetings and friendly gestures.
China has authorized exports from 45 Brazilian meat plants, helped by visits earlier in the year by Vice President Hamilton Mourao and Agriculture Minister Tereza Cristina Dias.
Chinese state oil companies CNOOC and CNODC were the only bidders other than Brazil's own state-run Petroleo Brasileiro SA in a massive oil auction last week, following an invitation made by Bolsonaro during his visit to the Asian nation.
Senior Chinese officials told reporters last week they hope the summit will help "inject confidence into a worried international community" and "uphold multilateralism in the face of unprecedented challenges and rising protectionism."
Agree To Disagree
Most notable perhaps will be a desire to avoid confrontation over Venezuela, a key point on which Brazil disagrees with Russia and China. It will be discussed, though not publicly.
"Venezuela is not off the table, but it will not be mentioned in the joint declaration," a diplomat from one BRICS nation said, asking not to be named due to the sensitivity of the issue.
The resignation of Bolivian President Evo Morales on Sunday brought another division within BRICS, as Brazil welcomed his departure as opening the way to fair elections and Russia called it a coup.
Last week, diplomats at Brazil's Foreign Ministry laid out the BRICS agenda including beefing up cooperation in fighting terrorism and corruption.
The main thrust will, however, be to get the group's New Development Bank to lend more for infrastructure and other projects to boost growth. Created in 2014, the bank has taken time to get going, leading to impatience among member countries.
Even though it has now approved projects valued at a not-negligible $12 billion, there is a need for BRICS to move beyond speeches and speed up action in financing development, diplomats said.
Bank executives, business leaders and officials are expected to discuss an expansion of the bank to include new members.