Australian opposition leader Bill Shorten has said late that the Labor Party would not be able to form government following elections.
Mr Shorten said he had called conservative Prime Minister Scott Morrison to congratulate him on the election result.
"And without wanting to hold out any false hope, while there are still millions of votes to count and important seats yet to be finalised, it is obvious that Labor will not be able to form the next government," he told disappointed Labor supporters at a function in Melbourne.
The coalition government is in position to win the national election with more than half the votes counted, media projected, though it is unclear whether it can govern with an outright majority and final results may not be known this weekend.
Mr Morrison said his government had delivered a miracle result in the election, saying the victory was for the "quiet Australians" who supported him.
"I have always believed in miracles!" he told an exuberant room of Liberal Party supporters around midnight.
The results stand in stark contrast to pre-election polls, which had predicted centre-left Labor would win.
The election may be the first anywhere decided on climate policy after a season of record floods, wildfires and droughts brought the environment front and centre in the campaign.
Former Australian prime minister Tony Abbott, infamous for once calling the science behind climate change "crap", has become the first big scalp of the election.
Mr Abbott, who was prime minister from 2013 to 2015, was one of the most vocal climate sceptics in parliament and had held his seat of Warringah in Sydney's northern suburbs for a quarter of a century.
But amid a groundswell of activism on climate change among his affluent beachside electorate and a strong challenge from independent candidate and former Olympian Zali Steggall, Mr Abbott was unable to hold on.
While the national election remained too close to call, Mr Abbott admitted his defeat less than three hours after polls closed.
Just weeks ago, the contest looked like it might be a rout for Labour, but Mr Morrison has narrowed the gap.
Mr Morrison took office last August after a party coup that ousted moderate pro-climate leader Malcolm Turnbull.
The election comes just days after the death of much-loved former prime minister and Labour leader Bob Hawke.