Australian Prime Minister Scott Morrison has thanked voters for re-electing his centre-right Coalition in a shock result at the federal polls.
He told supporters he had “always believed in miracles” as partial results showed the Liberal-National Coalition close to a majority.
Opposition Labor Party leader Bill Shorten has announced he is resigning after accepting defeat.
Exit polls had suggested a narrow Labor win for the first time in six years.
The final result of the election may not be known for some hours, but with more than 70% of votes counted the Coalition has won, or is ahead in, 74 seats in its quest for a 76-seat majority, with Labor on just 66 seats.
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.
‘The result nobody predicted’
By Hywel Griffith, BBC Sydney correspondent
Try finding someone who says they saw this result coming.
For well over two years, the coalition has trailed behind Labor in the opinion polls, and the assumption had been it would be Labor’s turn to govern.
But somehow Scott Morrison managed to turn things around at the 11th hour – and he did it largely on his own.
With some of his cabinet colleagues considered too toxic to appear in public on the campaign trail, ScoMo made this election about him, and his ability to be the trustworthy, daggy-dad Australia needed.
In the end, it was very, very close, but the voters decided, on balance, he deserved the fair go he craved.
What are the leaders saying?
“It is obvious that Labor will not be able to form the next government,” Mr Shorten told Labor Party members.
He said he had called Mr Morrison to congratulate him, and announced he would not stand for re-election as Labor leader.
Thanking his opponent, Mr Morrison paid tribute to “the quiet Australians” who had voted for the Coalition.
“It has 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!”
“I said that I was going to burn for you, and I am, every single day,” he added.
Mr Morrison’s second-in-command, Treasurer Josh Frydenberg, fought off a strong challenge for his seat in Melbourne. He attributed the Coalition’s success to “the economic choice” made by voters.
In Sydney, Liberal supporter Greg Napper summed up the mood for Reuters news agency: “I thought I was coming to a wake, to be quite honest with you. This is a party – the results are encouraging.”
Why is the election important?
Saturday’s vote is the first general election since political infighting ousted Australia’s fourth leader in a decade.
Mr Morrison says he has united his conservative government – a coalition between his Liberal Party and its traditional ally the National Party – in the nine months since he replaced Malcolm Turnbull.
But Mr Shorten pressed his case with stark policy alternatives, promising to cut tax breaks for the wealthy and to lower greenhouse gas emissions.
“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 managed to convince people they should be afraid of change.”
Australia holds elections every three years, but no prime minister has succeeded in serving a full term since 2007.
Former Liberal Prime Minister Tony Abbott conceded he had lost his seat in Warringah to former Olympic skier Zali Steggall.
“I can’t say that it doesn’t hurt to lose,” he told supporters, but added: “I’d rather be a loser than a quitter.”
In another development, controversial right-winger Fraser Anning lost his Senate seat.
While in the Senate, he had called for preference to be given to white immigrants, used the Nazi-related phrase “final solution” while discussing immigration, and blamed the Christchurch shootings on Muslim immigration.
What have been the key issues?
Surveys showed that the economy, cost of living, environment and health were central concerns for voters.
It has been in many ways a generational issue election, experts say, with younger people in particular voicing frustration about climate change and a lack of affordable housing.
Others have argued that older Australians would be most affected by tax reform proposals that have dominated much of the campaign.
The vote follows fierce debates about the rolling leadership turmoil, formal recognition of indigenous Australians, and the treatment of female MPs in parliament.
What did the contenders campaign for?
As the Liberal-National government seeks its third term, Mr Morrison says he has healed bitter internal divisions that brought down Mr Turnbull.
He has campaigned primarily on economic issues, often doing so alone while painting the election as a choice between himself and Mr Shorten.
Mr Shorten, who has led Labor for six years, has instead emphasised his team’s stability and policies on climate change, cost of living and health.
Also vying for support are minor parties including the Greens, One Nation and the United Australia Party, as well as a raft of independents.
How did the vote work?
Australian elections always take place on Saturdays. This time about 7,000 polling stations were set up across the nation, the Australian Electoral Commission (AEC) said.
But people could vote early at pre-polling stations, and a record number – more than four million people – elected to do so in 2019.
Because voting is compulsory, anyone aged over 18 faces a A$20 (£11; $14) fine for not taking part.
At the last election, 95% of Australians voted – a much higher proportion than the most recent US (55%) and UK (69%) polls.
If you have a question about the Australian election you can send it to us via the form below.
If you are reading this page and can’t see the form you will need to visit the mobile version of the BBC website to submit your question.