Australian Prime Minister Scott Morrison is close to securing a majority government as the election's final results are being counted.
His conservative coalition has defied polls and is leading with 77 seats, the Australian Electoral Commission says. Only 76 are needed for a majority.
"I've always believed in miracles," Mr Morrison told supporters in his victory speech on Saturday night.
Exit polls had predicted a Labor Party win for the first time in six years.
Labor leader Bill Shorten resigned in the wake of his party's surprise defeat, telling members: "It is obvious that Labor will not be able to form the next government."
He will not seek re-election as party leader.
The final result may not be known for some hours, but with more than 76% of votes counted the Liberal-National Coalition has won or is predicted to win 77 seats, with Labor trailing on 68 seats.
If the coalition fails to win an outright majority it will need the help of independent MPs to govern.
Australia has mandatory voting and a record 16.4 million voters enrolled for the election, which returns a new House of Representatives and just over half of the seats in the Senate.
In his victory speech on Saturday night, Mr Morrison paid tribute to "the quiet Australians" who voted for the coalition.
"It's been those Australians who have worked hard every day, they have their dreams, they have their aspirations, to get a job, to get an apprenticeship, to start a business, to meet someone amazing," he said.
"To start a family, to buy a home, to work hard and provide the best you can for your kids. To save for your retirement. These are the quiet Australians who have won a great victory tonight!"
On Sunday morning, he joined a service at the Pentecostal Horizon Church in Sydney, where he thanked the congregation for their support.
"You don't get to be a prime minister and serve in that capacity unless you first are a member of your local electorate."
He later watched his team, the Cronulla Sharks, play a rugby league match, drawing cheers from the crowd.
Why was the election important?
Australia holds elections every three years but, with infighting rife, no prime minister has succeeded in serving a full term since 2007.
Mr Morrison said he had united his government - a coalition between his Liberal Party and its traditional ally, the National Party - in the nine months since he replaced Malcolm Turnbull as prime minister.
Surveys showed that the economy, cost of living, environment and health were central concerns for voters, while younger people in particular voiced frustration about climate change and a lack of affordable housing.
Mr Morrison campaigned primarily on economic issues, often doing so alone while painting the election as a choice between himself and Mr Shorten.
Mr Shorten promised to cut tax breaks for the wealthy and to lower greenhouse gas emissions.
There were fierce debates about the rolling leadership turmoil, formal recognition of indigenous Australians, and the treatment of female MPs in parliament.
"I think people have become afraid after a very negative campaign," Labor supporter Julie Nelson told Reuters at the party's Melbourne election night function. "They [the Liberals] managed to convince people they should be afraid of change."
Sorry, your browser cannot display this map