BIARRITZ, France -- He may have spent the weekend an ocean away from home, rubbing elbows with world leaders during tense talks on international crises, but Prime Minister Justin Trudeau kept cool, collected and decidedly out of the fray.

For a political leader who thrives in the flash of cameras and curated social media content, it was an uncharacteristic approach for Trudeau at the G7 summit in Biarritz, France, which wrapped up Monday.

With the start of an election campaign just weeks away, Trudeau kept things low-key. He steered a wide berth around the debris field trailing U.S. President Donald Trump, save for one largely uneventful bilateral meeting, and stayed focused squarely on the Liberal party's key election talking points: the economy, taking action on climate change and raising the fortunes of the middle class.

In their meeting Sunday, Trudeau praised the new, albeit not yet ratified, free trade agreement between Canada, the U.S. and Mexico, a favourite subject of Trump's. Gone was the tough talk about Canada not being pushed around -- a sentiment that triggered a Twitter tantrum from the confines of Air Force One in the final moments of last year's G7 meeting in Charlevoix, Que.

It seemed to work: when right-wing commentator and Rebel Media founder Ezra Levant called out Trudeau on Twitter for what he called "submissive" body language, Trump himself came to the prime minister's defence.

"No, we actually had a very good and productive meeting," Trump tweeted in response to Levant. "Nice!"

In each and every bilateral meeting with a world leader he held on the margins of the two-day summit -- Trump, U.K. Prime Minister Boris Johnson, German Chancellor Angela Merkel and French President Emmanuel Macron, among others -- Trudeau made sure to mention trade, the global economy and climate issues.

Indeed, climate was top of mind throughout the weekend, thanks to the wildfires ravaging the Amazon rainforest and burning up social media feeds around the world.

Canada pledged $15 million and the use of Canadian water bombers to help; Macron also announced a US$20-million commitment from the G7, part of which is to be earmarked for a long-term global initiative to protect the rainforest. Any link between the two was unclear, however -- officials appeared to be at a loss when asked whether the Canadian money was part of Macron's announcement or a separate offer of help.

The money the G7 nations put forward for the Amazon will be aimed specifically at Brazil, Bolivia, Peru and Paraguay, said Chilean President Sebastian Pinera, with urgent brigades to combat fires and specialized planes. "We think we have to protect these real lungs of our world," Pinera said.

Brazilian President Jair Bolsonaro, a populist, far-right leader who initially dismissed the gravity of the threat, relented Friday and promised 44,000 soldiers to help battle the blazes, which mostly seem to be charring land deforested for farming and ranching rather than burning through stands of trees.

Trudeau wasn't the only world leader hoping to quell any suggestion of discord. Both Trump and Macron sounded notes of unity as the gathering wrapped up, a markedly different tone from last year, when Trump demanded his name stricken from the shared communique.

This time, leaders opted instead for a short, single page of statements about the economy, Iran and Hong Kong, among other global hotspots.

"We actually had a very good meeting," Trump said at a press conference of his own.

"I had it out with one or two people where we disagreed in terms of concept, but we actually had a pretty good meeting last year. I would say that this was a big step above in terms of unity, in terms of agreement. We have really great agreement on a lot of important subjects, but last year was good also."

He added: "Last year might have been a little bit underrated."

Fissures between the U.S. and six of the world's other advanced economies were apparent, however, on issues including trade policy, Russia, Iran and climate change. Trump skipped the climate session, and repeated his push to invite Russia -- ousted in 2014 over the annexation of Crimea -- back into the group. That's not about to happen, Trudeau insisted.

His closing remarks sounded a lot like a stump speech -- to say nothing of the Liberal campaign ad that happened to drop early Monday morning.

"Around the world, hard-working middle class people are already having a hard time making ends meet, even with a growing economy, " Trudeau said.

"They're worried about their jobs, about their businesses, about their future. They wonder what this uncertainty around the global economy means for their retirement, for their kids, for their communities. We in Canada believe that we should put the best balance sheet in the G7 to work for the middle class."

He denied any sort of pre-campaign strategy was in play -- it just so happens that the G7's priorities happen to align with the priorities of ordinary Canadians, he said.

"When we had the opportunity to host the G7 last year, our focus was on the global economy, on growth for the middle class and indeed on climate and oceans. The year before that, we brought forward strong issues on the global economy and climate change. These are the issues that matter to Canadians and indeed to people around the world, and we will always highlight them in our actions and in our engagements," Trudeau said.

"I'm going to continue to do that at every opportunity I get to serve and represent Canadians both at home and on the world stage."

-----

With files from The Associated Press