Under pressure from allies, U.S. President Donald Trump backed a pledge to fight protectionism on Saturday, but refused to endorse a global climate change accord, saying he needed more time to decide.

The summit of Group of Seven wealthy nations pitted Trump against the leaders of Germany, France, Britain, Italy, Canada and Japan on several issues, with European diplomats frustrated at having to revisit questions they hoped were long settled.

Trump, who has previously called global warming a hoax, tweeted that he would make a decision next week on whether to back the 2015 Paris Agreement on curbing carbon emissions following lengthy discussions with G7 partners.

"The entire discussion about climate was very difficult, if not to say very dissatisfying," German Chancellor Angela Merkel told reporters. "There are no indications whether the United States will stay in the Paris Agreement or not."

However, there was relief that Trump agreed to language in the final G7 communique that pledged to fight protectionism and commits to a rules-based international trade system.

During his election campaign last year, Trump threatened unilateral tariffs on Mexican and Chinese goods and said he would quit the North American Free Trade agreement unless it is renegotiated to his liking. Earlier this week he called Germany "very bad" on trade because of its surplus with the United States.

"In the end we convinced them to include the fight against protectionism in the final communique, so that was a step forward," said one European diplomat, who declined to be named.

Meeting in a luxury hotel overlooking the Mediterranean sea, hosts Italy had hoped that the summit would focus on Europe's migration crisis and the problems of neighbouring Africa.

The internal G7 divisions and a suicide bombing in Britain on Monday, that killed 22, overshadowed the Italian agenda, but on Saturday five African leaders joined the world power leaders to discuss their continent's potential.

Niger President Mahamadou Issoufou urged the G7 to take urgent measures to end the crisis in Libya -- the point of departure for hundreds of thousands of migrants looking for a better life in Europe. He also criticised them for not honouring aid promises to fight poverty in West Africa's poorest regions.

"Be it Niger, a transit nation, or the countries of origin, it is only through development that we will prevent illegal migration," Issoufou said.

RUSSIAN STICKING POINT

The final communique was just six pages long, against 32 pages last year, with diplomats saying the leaders wanted a simpler document to help them reach a wider audience.

After lengthy deliberation, the document included a separate threat, that was inserted into the 2016 G7 statement, to take additional action against Russia, if warranted, for its intervention in Ukraine.

The European Union and the United States imposed sanctions on Russia after Moscow annexed Crimea from Ukraine in 2014 and pledged to up the penalties if Russian interference in Ukraine intensified. Trump's promise of warmer ties with Moscow had called into question the U.S. commitment to sanctions.

Diplomats said that on other key international issues, such as Syria and North Korea, there was broad G7 agreement.

However, Italy was disappointed not to receive more backing for its call to open up more legal channels for immigration to try to slow the flow of people risking their lives to reach Europe on flimsy boats from lawless Libya.

"There was very strong opposition by the Americans and British who wanted to refocus on security and water down the expansive language on freedom of movement," said a European diplomat, who declined to be named.

Security questions dominated initial G7 discussion on Friday and the leaders called on internet service providers and social media firms to "substantially increase" their efforts to rein in extremist content.

The U.S. president is due to return to Washington later on Saturday at the end of a nine-day tour of the Middle East and Europe -- his first foreign trip since taking office.

Unlike other G7 leaders, he is not due to give a press conference before flying out.

U.S. officials said he had enjoyed "robust" conversations with his allies in Sicily and had also learnt a lot -- especially in the debate on climate change, which he has previously dismissed as a hoax.

"He came here to learn. He came here to get smart. His views are evolving which exactly as they should be," Trump's economic adviser Gary Cohn said on Friday.