Leaders of the Group of 20 nations have deplored Russia's aggression in Ukraine "in the strongest terms" and demanded its unconditional withdrawal in a declaration adopted at the end of a two-day summit.
"Most members strongly condemned the war in Ukraine," the declaration said, signalling that Russia, which is a member of G20, opposed the wording.
The positions taken by China and India, which abstained from a similar UN resolution in March, were not immediately clear.
However, at least three diplomats said the statement, which recognised that "there were other views and different assessments of the situation and sanctions", was unanimously adopted.
"The use or threat of use of nuclear weapons is inadmissible," the declaration also said.
"It is essential to uphold international law and the multilateral system that safeguards peace and stability. This includes defending all the purposes and principles enshrined in the Charter of the United Nations and adhering to international humanitarian law."
Earlier, Wednesday's schedule at the summit on the Indonesian island of Bali was disrupted by an emergency meeting to discuss reports of a missile landing in Polish territory near Ukraine on Tuesday, killing two people.
US President Joe Biden said after the meeting that the United States and its NATO allies were investigating the blast but early information suggested it may not have been caused by a missile fired from Russia.
NATO member Poland had said a rocket killed two people in eastern Poland near Ukraine, and it summoned Russia's ambassador for an explanation after Russia denied it was responsible.
The G7 nations include the United States, Germany, France, Canada, Italy, Britain and Japan.
After the meeting, the G20 leaders, dressed in white shirts and some with baseball caps with the G20 logo, took part in a ceremony to plant mangrove saplings to signal the battle against climate change.
On the sidelines of the summit, US Treasury Secretary Janet Yellen held a two-hour meeting with Chinese central bank Governor Yi Gang, her first in-person talks with a senior Chinese economic official.
She had said before the meeting she hoped to get new insight into China's policy plans and work toward more economic engagement between the two countries.
WTO Director-General Ngozi Okonjo-Iweala told Reuters on the summit sidelines that several major economies faced a real risk of sliding into recession as the war in Ukraine, rising food and fuel costs, and soaring inflation cloud the global outlook.
The Western-led push to condemn Russia's invasion of Ukraine dominated the summit.
Many participants said President Vladimir Putin's invasion of Ukraine had pummelled the global economy and revived Cold War-era geopolitical divisions just as the world was emerging from the worst of the COVID-19 pandemic.
Russia has said "politicisation" of the summit was unfair.
"Yes, there is a war going on in Ukraine, a hybrid war that the West has unleashed and been preparing for years," Foreign Minister Sergei Lavrov said on Tuesday, repeating Putin's line that NATO's expansion had threatened Russia.
Lavrov was representing Putin at the summit but left on Tuesday evening.
The West has accused Russia of making irresponsible statements on the possible use of nuclear weapons since its invasion of Ukraine. Russia has in turn accused the West of "provocative" nuclear rhetoric.
G20 host Indonesia has pleaded for unity and a focus on problems like inflation, hunger and high energy prices, all exacerbated by the war.
The summit document also said G20 central banks would calibrate monetary tightening with an eye on the global inflation problem, while being mindful of the need to limit "cross-country spillovers".
The G20 members also reaffirmed their commitment to avoid excessive exchange-rate volatility while recognising that "many currencies have moved significantly" this year.
On debt, it voiced concern about the "deteriorating" situation of some middle-income countries and stressed the importance of all creditors sharing a fair burden.