Greece’s conservative New Democracy Party prevailed in elections Sunday, giving it the chance to form a new coalition government that would try to comply with the difficult terms of the country’s bailout and secure its spot in the euro zone.

After weeks of uncertainty, the outcome of the parliamentary elections could reassure international leaders and investors, who have nervously watched developments in Greece, fearful that its exit from the euro zone would rock the global economy.

In a short victory speech, New Democracy leader and likely prime minister Antonis Samaras called the outcome a “victory for all Europe.”

“Today the Greek people expressed the will to stay anchored within Europe, honor their commitments and foster growth,” Samaras said. He called on the other parties to “join forces to form a stable government. . . . There’s no time to lose.”

New Democracy finished comfortably ahead of the leftist Syriza coalition, whose 37-year-old leader, Alexis Tsipras, had threatened to discard the bailout agreement.

That agreement, which requires the cash-strapped Greek government to adopt a series of deep spending cuts and tax increases, was struck with the International Monetary Fund and other international lenders.

A showdown could have forced Greece out of the currency union, setting off dangerous ripple effects with investors suspecting that other struggling European countries, such as Italy and Spain, also might not be able to meet their obligations. The result could have been a series of domino-like exits from the euro zone, ultimately causing the disbanding of the currency union and economic chaos.

Greece’s economic plight and Europe’s broader problems have become one of the chief risks to the world economy, and will be a focus of talks when President Obama and other Group of 20 leaders meet in Mexico this week. Europe’s troubles already are buffeting the U.S. economy, making them a matter of immediate concern for Obama’s reelection efforts.

Tsipras said he had called Samaras to congratulate him but would be an aggressive opposition leader. The austerity demands of the bailout “are not sustainable, and the government with New Democracy as a core should take this into account,” Tsipras said.

Previous vote inconclusive

An earlier round of elections last month ended inconclusively, failing to produce a new government. At the polls Sunday, both New Democracy and Syriza increased their share of the vote from the previous contest. New Democracy took around 30 percent of the national tally and Syriza about 27 percent.

The first-place finish gives Samaras the right to try to build a majority coalition in the country’s 300-member Parliament — and a 50-seat bonus toward that end. Coupled with the seats New Democracy won outright, Samaras would carry perhaps 130 seats into the upcoming coalition talks.

The coming days will see him bargain with the country’s other parties, most notably the Panhellenic Socialist Movement, or Pasok. The Socialist party has alternated power with New Democracy throughout Greece’s modern history but crashed in the May election in the face of Syriza’s rise as a protest against the economic program that Pasok’s leaders negotiated with the IMF.

Pasok finished third Sunday. It won enough seats that if it joined with New Democracy, Samaras would be able to form a pro-bailout government. But in earlier statements, Pasok officials said they would not enter a coalition unless it was part of a larger national unity government that included Syriza. That scenario is unlikely, given Syriza’s anti-bailout stance.

Nation is divided

The strong showing Sunday by Syriza — 25 percent of the vote is substantial in Greece’s divided politics — was a sign of how ambivalent Greeks remain about the bailout. The nation is deeply divided over whether the emergency loans are worth the strict conditions imposed by the IMF and the European countries putting up the money.

But Greek voters were not ready to risk wholesale change — and, under Tsipras, a possible clash with Europe and exit from the euro zone.

Samaras, a Harvard-trained MBA, endorsed bailout efforts for Greece while he was an opposition leader in recent years.

He is considered by the IMF and other European nations to be a constructive partner in upcoming talks about the future of the program.

A Samaras-led government could also include the smaller Democratic Left party, strengthening his ability to pass legislation and take other steps required under the detailed memorandum signed by the Greek government just a few weeks ago in return for international loans.

Rescue plan running behind

Once a government is formed, the new prime minister will open talks with the IMF, the European Commission and the European Central Bank to restore the flow of international bailout funds needed to keep Greece’s government and banking system afloat. Over several weeks of political stalemate, the country’s financial rescue plan has slipped behind schedule, and international officials are likely to want fresh commitments from the Greek government.

But there will be demands from Greece as well. Samaras has said he will ask to slow the timetable of budget cuts and other changes expected under the bailout program.

At polling places in well-to-do neighborhoods in the shadow of the Parthenon and in working-class enclaves, voters shared a frustration over the country’s circumstances and said they hoped the election would ease conditions regardless of the outcome.

“We’ve lost our dignity,” said 58-year-old Kostas Lazaridis, a Syriza supporter, as he thumbed a set of worry beads outside the graffiti-covered High School Number 12 in the capital’s Kato Petralona neighborhood. “Change should not be radical, but it is crucial. We have to put a stop to this.”