In addition, Greece will get a new $140 billion bailout early next year, government leaders said.
The accord, reached shortly before 4 a.m. Brussels time (10 p.m. EDT Wednesday), came after hours of fractious debate.
"Because of the complexity of the issues at stake it took us a full night," French President Nicolas Sarkozy told reporters. "But the results will be a source of huge relief worldwide."
U.S. European and Asian stock indexes were all sharply higher Thursday.
The Dow Jones industrial average closed up 2.9 percent. The Nasdaq composite index and the Standard & Poor's 500 index gained 3.3 percent and 3.4 percent, respectively.
The pan-European Stoxx 600 index surged 3.6 percent to end at 249.42. France's CAC-40 index soared 6.3 percent and Germany's DAX 30 index rose 5.4 percent. Britain's FTSE 100 index advanced 2.9 percent.
Greece's ASE composite index gained 4.8 percent, with shares of National Bank of Greece up 6.1 percent.
Japan's Nikkei 225 index closed 2 percent higher and the Hong Kong Hang Seng climbed 3.3 percent.
In a statement, U.S. President Barack Obama called the accord "a critical foundation for a comprehensive solution to the Eurozone crisis."
"The key now is to make sure that there is strong follow-up, strong execution of the plans that have been put forward, but I was very pleased to see that the leaders of Europe recognize that it is both in Europe's interest and the world's interest that the situation is stabilized," Obama said on the question of whether there is enough firepower in the accord to avert a double-dip recession.
In the statement, he said, "We will continue to support the EU and our European allies in their efforts to address this crisis as we work together to sustain the global recovery and put our people back to work," Obama said.
Based on the deal, private banks will take a "voluntary" 50 percent loss on the face value of their Greek debt, euphemistically called a "haircut," Sarkozy said.
The governments had wanted a 60 percent loss. The banks originally agreed to a 21 percent loss.
Bank representative Charles Dallara of the Institute of International Finance, an international bank lobby group based in Washington, had said too radical a deal couldn't be called "voluntary" and would spread Greece's economic problems like a disease to relatively healthy economies across the eurozone.
But Sarkozy at one point warned Dallara if he didn't make a deal, Greece would likely default and the private creditors would lose 100 percent of their investments, The Wall Street Journal reported.
The deal will be supported by $42 billion of "official funding" from the bailout fund to provide guarantees for bondholders who accept the deal, he said.
Greece's debt, currently at 160 percent of its gross domestic product and projected to peak at 186 percent, would be reduced to 120 percent of GDP by 2020, officials said.
Sarkozy said the leaders agreed to expand the size of the eurozone's bailout vehicle, known as the European Financial Stability Facility, to about $1.4 trillion from the $350 billion remaining in it so it could guarantee bonds issued by financially struggling countries such as Spain and Italy.
The deal includes requiring Europe's 70 biggest banks to raise about $150 billion by June 2012 to protect themselves against losses on loans to shaky countries like Greece and Portugal.
President Obama and other world leaders were to arrive in Cannes, France, Nov. 3 for a two-day Group of 20 summit meeting, expecting Europe will no longer be a drag on the global economy, The New York Times reported.
Ukrainian protestors topple Lenin statue [VIDEO]
Selena Gomez drops F-bomb, walks off stage during Jingle Ball performance