With 99% of ballots counted, New Democracy had won 29.7% of the vote, ahead of Syriza on 27%. New Democracy leader Antonis Samaras will need the PASOK Socialists, for decades Greece's largest party and now humbled by angry voters, to form a government.
The result came as a relief for Greece's EU and IMF lenders and eurozone partners who feared a Syriza victory would tip Greece over the edge and the common currency towards break-up.
A 50-seat bonus given to the party which comes first would give New Democracy 129 seats in the 300-seat parliament. Syriza will have 71 MPs, followed by PASOK with 33 MPs, ANEL or Independent Greeks (right wing, anti-austerity) with 20 MPs, Golden Dawn (extreme right) with 18 MPs, DIMAR or Democratic Left (pro-European) with 17 MPs and the Communist Party KKE with 12 MPs.
Following the announcement of the results, Samaras called for broad support over the Syriza party, which said it would cancel the aid deal agreed in March to avert bankruptcy in defiance of the country's lenders.
"There is no time to waste," Samaras told reporters in Athens as jubilant, chanting supporters waved blue party flags. "A national salvation government must bring economic growth and reassure Greeks the worst is over."
Relegated to third place in an earlier, inconclusive 6 May election (see background), PASOK said it wanted a broad coalition that would include Syriza, but that the most important goal was to form a government and put an end to political uncertainty.
The election result also brought cheers at the headquarters of Syriza. The leftists rode a wave of discontent over austerity and corruption and see second place as a victory for a party that has long been on the fringes of Greek politics.
Syriza leader Alexis Tsipras, 37, made clear his was now the main opposition party, saying it would fight on against the bailout and take power sooner or later.
"Very soon, the Left will be in power," the former communist and student protest leader told supporters in Athens after conceding defeat. "We begin the fight again tomorrow."
Greece is under international pressure to form a government as soon as possible, because it will run out of cash to pay its employees in July. Some analysts put the cost of a Greek exit from the eurozone for the European economy as high as €1 trillion.
Its caretaker government says the state has enough cash to last a few weeks and Athens has pledged to come up with an additional €11.7 billion worth of spending cuts in June to merit the next loan instalment.
The new government might get a helping hand from its eurozone peers with Germany's foreign minister suggesting Athens might get more time to implement the cuts demanded of it.
But most economists say even that would leave Greece, into a fifth year of deep recession, facing a programme it cannot hope to deliver on.
The vote revealed a society deeply split between its desire to stay in the euro and a deep-seated anger at salary, pension and job cuts that have hit the poorest while sparing a political and business elite seen by many as corrupt.
A protest vote looked set to give the ultra-right Golden Dawn party 18 seats, repeating its success of 6 May despite a now-notorious incident in which its spokesman threw water at one leftist opponent and slapped another during a TV debate.
Analysts say a pro-bailout coalition may not last, having commanded only slightly more than 40% of the vote and being pressed to make more savings from lenders.
More than two years of budget cuts have caused unemployment to jump to over 22%. Businesses are shutting down by the dozen and the homeless are multiplying on the streets of Athens.
Both New Democracy and PASOK have said they want to renegotiate the terms of the bailout to spread the burden over a longer period and take measures to boost growth.
Greece's EU partners and the International Monetary Fund welcomed the pro-bailout parties' victory, saying they were ready to work with the government that emerges. But EU officials have made clear Greece must stick to its pledges to receive more funding while hinting there may be some leeway at the margins.
"There can't be substantial changes to the agreements but I can imagine that we would talk about the time axes once again, given that in reality there was political standstill in Greece because of the elections, which the normal citizens shouldn't have to suffer from," German Foreign Minister Guido Westerwelle said.