G7 leaders have issued a joint pledge to combat protectionism and cut trade barriers as they wrapped up a fractious summit in Canada soured by a row over the US imposition of tariffs on its allies.

After two days of often fierce arguments between the United States and both the summit hosts and Europe, the organisation issued a joint statement which attempted to paper over their cracks.

But the attempts to convey at least a semblance of unity were undermined when Canada's Prime Minister Justin Trudeau confirmed he was going ahead with his tariffs against the US in response to US moves against his country's steel and aluminium industries.

The eight-page statement also included joint commitments to ensure that Iran will "never seek, develop or acquire a nuclear weapon" as well as demands for Russia to stop undermining Western democracies.

There was also an agreement to disagree on climate change in the wake of Donald Trump's decision to leave the Paris climate accord last year which further underlined the divide between the Group of Seven's powerhouse and its six co-members.

During the summit, Mr Trump was accused of seeking to undermine the "rules-based" international order but the final statement began by stressing "the crucial role of a rules-based international trading system" as well as a commitment to "continue to fight protectionism."

But in an apparent nod to Mr Trump, it also pledged to push for swift reforms to the World Trade Organisation which the US president has said has been a "disaster" for his country.

"We commit to modernise the WTO to make it more fair as soon as possible. We strive to reduce tariff barriers, non-tariff barriers and subsidies."

Speaking at a post-summit press conference, Mr Trudeau acknowledged that there were major differences with Mr Trump.

"What we did this weekend was come together, roll up our sleeves and figure out a consensus language that we could all agree to," he said in the town of La Malbaie where leaders have been meeting since Friday morning.

"Obviously the president will continue to say what he says."

Mr Trudeau again denounced Mr Trump's decision to invoke national security concerns to impose tariffs on aluminum and steel as "insulting" to the Canadian war veterans who had fought alongside US allies.

And he said he told Mr Trump "it would be with regret but it would be with absolute clarity and firmness that we move forward with retaliatory measures on July 1, applying equivalent tariffs to the ones that the Americans have unjustly applied to us."

Mr Trump left the summit early headed for his meeting with the leader of North Korea next Tuesday.

But in a tweet after flying out of Canada, the US president showed he was in no mood to back down in any trade dispute.

"The United States will not allow other countries to impose massive Tariffs and Trade Barriers on its farmers, workers and companies. While sending their product into our country tax free," he said.

"We have put up with Trade Abuse for many decades - and that is long enough."

Mr Trump had earlier told the G7 leaders that the United States wanted a quick end to trade practices that he says have led to an exodus of American companies and jobs to other countries.

Mr Trump, who angered his G7 partners last week with tariffs on steel and aluminium imports from Canada, the European Union and Mexico as part of his "America First" agenda, vowed to hold firm until US goods had "fair" access to markets.

"The United States has been taken advantage of for decades and decades," Mr Trump said at a press conference at the summit in Canada.

"We're like the piggy bank that everybody is robbing," he added.

Mr Trump suggested to the other G7 leaders that all trade barriers, including tariffs and subsidies, be eliminated.

"You go tariff-free, you go barrier-free, you go subsidy free," he said. "I did suggest it and people I guess were going to go back to the drawing board."

Mr Trump denied that the summit had been contentious, a remark that contradicted what one G7 official described as a bitter harangue on Friday between the US president and his counterparts over tariffs.

In an "extraordinary" exchange, Mr Trump repeated a list of grievances about US trade, mainly with the EU and Canada, a French presidency official told reporters.

"And so began a long litany of recriminations, somewhat bitter reports that the United States was treated unfairly, that the trading system was totally unfavorable to the United States, the American economy, American workers, the middle class," the official said.

"In short, a long, frank rant which is undoubtedly very unusual in this kind of formats," the official added.

French President Emmanuel Macron responded in a "courteous but very firm tone" to present the European side of the story, and Japanese Prime Minister Shinzo Abe chimed in as well, the official said.

Read more:

Trump calls for re-admission of Russia to G7 ahead of summit
Trump's points of friction with G7

Despite the apparent acrimony, it is likely that the G7 - which groups the United States, Canada, Great Britain, France, Italy, Germany and Japan - will issue a final communique at the end of the summit, a diplomatic source said.

Mr Trump arrived late for the first working session today on gender equality but Canadian Prime Minister Justin Trudeau forged ahead with opening remarks without him, commenting wryly about "stragglers."

Mr Trump planned to leave the summit early before it discussed climate change and the health of oceans, underlining fractures in the G7 exacerbated by the tariffs.

He is due to fly to Singapore to meet with North Korean leader Kim Jong-un, which he described as a "mission of peace."

Still, the United States and the EU will establish a dialogue on trade within the next two weeks, signaling a modest step forward for the bitterly divided allies of the G7.

Mr Trump's early departure means he will miss a working session among the leaders on climate change and clean energy, as well as talks among the G7 and poorer countries focused on the health of oceans.

He will also be gone before allies begin closing news conferences likely to be critical of the US stance on trade and Mr Trump's suggestion that Russia be re-admitted to the G7.

Russia was suspended from the group in 2014 because of its annexation of Crimea from Ukraine.

German Chancellor Angela Merkel said EU countries at the summit agreed that the conditions to readmit Russia had not been met and even Moscow seemed to reject the suggestion.

Mr Trump's presidency has been clouded by a federal investigation into alleged Russian meddling in the 2016 presidential election, and possible collusion by his campaign.

Both Moscow and Trump have denied the allegations.