The World Trade Organisation has reached its first ever trade reform deal.
The deal was reached to a roar of approval from nearly 160 ministers.
The ministers had gathered in Bali to decide on the make-or-break agreement that could add $1 trillion to the global economy.
The approval came after Cuba dropped a last-gasp threat to veto the package of measures.
"For the first time in our history, the WTO has truly delivered," WTO chief Roberto Azevedo told exhausted ministers after the talks which had dragged into an extra day on the tropical resort island.
"This time the entire membership came together. We have put the 'world' back in World Trade Organization," he said. "We're back in business...Bali is just the beginning."
The talks, which had opened last Tuesday, nearly came unstuck at the last minute when Cuba suddenly refused to accept a deal that would not help pry open the US embargo of the Caribbean island, forcing negotiations to drag into this morning.
Cuba later agreed on a compromise with the United States.
The talks had begun under a cloud because of an insistence by India that it would only back an agreement if there was a compromise on food subsidies because of its massive programme for stockpiling food to feed its poor.
India, which will holds elections next year, won plaudits at home for taking a stand on behalf of the world's poor.
An eventual compromise was greeted with jubilation by Trade Minister Anand Sharma.
While India had insisted on a permanent exemption from the WTO rules, the final text aimed to recommend a permanent solution within four years.
But the agreement is a milestone for the 159 WTO members, marking the organisation's first global trade agreement since it was created in 1995.
It also rescues the WTO from the brink of failure and will rekindle confidence in its ability to lower barriers to trade worldwide, after 12 years of fruitless negotiations.
The deal would lower trade barriers and speed up the passage of goods through customs.
Analysts estimate that over time it could boost the world economy by hundreds of billions of euro and create more than 20m jobs, mostly in developing countries.
It still needs to be approved by each member government.