After five years of extreme austerity prescribed to treat an epidemic of debt, a battered but defiant Greece on Sunday emphatically rejected the medicine.

With millions of voters turning out — from graffiti-scarred lanes in the Parthenon’s shadow to islands lapped by aqua-green waves — the country delivered a historic win to Syriza, a radical leftist party that could put Greece on a collision course with the rest of Europe. The expected showdown has already rattled Greek financial markets and may challenge the core principle behind Europe’s currency union.

As thousands of party supporters cheered in the streets of Athens on Sunday night, nearly complete returns showed that Syriza had defeated its rivals by an unexpectedly wide margin. Though the total appeared just below the level of support needed to form a government without a coalition partner, Syriza’s charismatic young leader trumpeted the results as a new beginning for his beleaguered nation.

“The verdict of the Greek people ends, beyond any doubt, the vicious circle of austerity in our country,” Alexis Tsipras, 40, told a crowd of ebullient Greeks in a victory speech just before midnight at the marble-columned Athens Academy. “The verdict of the Greek people, your verdict, annuls today in an indisputable fashion the bailout agreements of austerity and disaster.”

Tsipras, who is likely to become prime minister within days, had campaigned on an upbeat if improbable platform of reviving the country’s beaten-down economy by turning on the taps of government stimulus. He vowed to hire back laid-off workers, raise the minimum wage, expand access to health insurance and provide electricity to those who can no longer afford it.

Those pledges resonated powerfully in a nation where a third of the population lives at or below the poverty line, following years of cuts and recession. But the election of the first radical leftist government in the history of the European Union represents a provocative challenge to the international creditors who bailed out Greece to the tune of $284 billion on the condition that the country rein in its bloated costs.

Once in government, the party has said, it will demand a renegotiation of the bailout terms and cancellation of a sizable chunk of Greek’s debt. The creditors, dominated by Germany, are unlikely to yield easily — raising fears of a showdown that ends with Greece exiting the euro, imperiling the rest of the currency union along the way.

“The whole idea of the euro is its irrevocability, and the moment you break that, you have no euro anymore,” said George Pagoulatos, a professor at the Athens University of Economics and a former government adviser. “This is a path down which no one wants to go.”

Even as the votes were being counted Sunday night, German officials dismissed the idea of any wholesale renegotiation, with central bank President Jens Weidmann telling state broadcaster ARD that Greece needs to stick to its commitments. “I hope the new government won’t call into question what is expected,” he said.

And yet, Greek voters appeared ready to risk a clash. With the economy in tatters, Greece has little to lose, they said, by gambling on a party promising radical change.

“The way things are right now, it’s impossible to survive,” said Helen Zorba, a 55-year-old civil servant who said her pay has been cut by 20 percent in recent years while her taxes have gone up. “People are losing their dignity. You shouldn’t have to go to the soup kitchen in order to live.”

Zorba proudly sported a colorful Syriza sticker on her denim jacket after casting her ballot in the working-class suburb of Nikea. She has backed the party for years, she said, even when it was barely pulling in 3 percent of the vote.

As the public’s desperation has risen, so has Syriza’s popularity, with middle-class voters abandoning the centrist parties that have dominated Greek politics for decades and casting their lot with a group dominated by Marxist university professors and Communist activists.

“People say Syriza doesn’t have the experience to govern. But the people who have the experience and the know-how to govern are the ones who failed Greece,” Zorba said.

Official results released Sunday evening showed Syriza had comfortably defeated its nearest rival, securing 36 percent of the vote compared with 28 percent for the incumbent center-right New Democracy party. Because the top party gets an additional 50 seats in the country’s 300-member Parliament, Syriza was close to the threshold needed to form a government on its own but seemed to have come up just short. Syriza was projected to take 149 seats — two short of a majority.

If that result holds, the party will need to form a coalition, and it will have three days in which to do it. The choice of partners is slim. The third-place party, with 6 percent of the vote, is the neo-fascist Golden Dawn, a non-starter for the leftists of Syriza. Two other parties that won a similar share of the vote — the centrist River and the nationalist Independent Greeks — are considered more likely, though each makes for a problematic match.

But few Syriza backers were thinking about that Sunday night. As the scale of the party’s victory became clear, thousands of people took to the streets of central Athens to cheer, dance, hug and sing along as revolutionary anthems blared from loudspeakers. Some hoisted banners emblazoned with the image of Latin American rebel Che Guevara. Hundreds of backers of an Italian neo-communist party brandished their party’s flag, which features a hammer and sickle.

Sunday’s vote was Greece’s third since 2012, and it came after the current government lost what amounted to a no-confidence measure in December.

In the campaign’s closing days, Prime Minister Antonis Samaras warned Greeks that leaving the path of austerity and challenging the country’s European creditors would lead the country to ruin. In a somber concession speech Sunday night, he took credit for an economy that has shown faint signs of improvement and said he hoped his gloomy forecasts for life under Syriza were wrong.

Samaras’s backers said they didn’t think so.

“It will be a catastrophe,” said Anna Ventouri, 45, a supermarket cashier who cast her ballot for the incumbents. “Tsipras says you can renegotiate the bailout, but it’s a big lie. It’s logical that if someone gives you a loan, they’re going to want that money back.”

In Greece’s case, that someone is German Chancellor Angela Merkel. A champion of fiscal rectitude who preaches the gospel of austerity for all that ails Europe, she is considered unlikely to grant Tsipras concessions that could embolden other emerging leftist movements across debt-ridden southern Europe.

Although both sides have softened their rhetoric in recent weeks, German leaders have also hinted at a tough line in any talks, with leaks to the media that they are prepared to see Greece leave the euro if a Syriza government tries to renege on its bailout commitments.

Syriza leaders, meanwhile, have been adamant that they do not intend to take Greece back to its pre-2001 currency, the drachma. But they have also said there is no backup plan if European negotiators refuse to budge in canceling Greek debt.

“It’s a game of chicken,” said Pagoulatos, the economist, in which “no one intends to crash.”

And yet, a crash could come. The smart move for Europe, Pagoulatos said, would be to co-opt Tsipras by giving him enough of what he wants to neutralize his assault on austerity.

But another option, he said, is for Merkel to dig in, and turn Greece’s leftist experiment “into a cautionary tale.”

It’s also possible that Syriza will stand in the way of a deal, with its disparate factions unable to agree on any package of concessions that falls short of the lofty promises made on the campaign trail.

“The rank-and-file has a component that is very radicalized,” Pagoulatos said. “They are not ready to accept the kind of compromise that the situation requires, especially after generating such expectations for a full rupture with the past.”

Sergio Tsitakis contributed to this report.