Australia appears to be heading for a hung parliament, with neither of the two main rivals likely to win the 76 seats needed for an outright majority.
ABC Australia is predicting 73 seats for the opposition coalition, 72 for ruling Labor, one for the Greens and four independents.
PM Julia Gillard vowed that she would "keep fighting".
Opposition leader Tony Abbott said it was clear Ms Gillard's Labor had lost its majority and its legitimacy.
The election comes two months after Ms Gillard ousted Kevin Rudd in a controversial leadership challenge.
'Back in business'
Australia has not had a hung parliament since 1940.
A handful of MPs may well hold the balance of power after the final result is known. The BBC's Nick Bryant, in Sydney, says they will try to get best deal they can for their constituencies and there may well be some pork barrel politics over the next few days as Ms Gillard and Mr Abbott try to gather some loose coalition or arrangement that will give them power.
Speaking to supporters in Melbourne, Ms Gillard quoted the words of former US President Bill Clinton when saying "the people have spoken but it's going to take some time to determine exactly what they have said".
"Obviously this is too close to call, there are many seats where the result is undecided and where it will take a number of days to determine the result.
"What we know is there will be a number of independents in the House of Representatives playing a role as the next government of Australia is formed.
"There are anxious days ahead, but I will keep fighting".
Mr Abbott told supporters in Sydney: "This is a night for pride in our achievements, satisfaction at the good results that have been achieved but also a measure of reflection on the magnitude of the task ahead."
He said the coalition was "back in business" and would try to form a government. Labor would "never be able to govern effectively in a minority", he said.
Mr Abbott said there should be "no premature triumphalism but an appreciation that this has been a great night for the Australian people".
"I feel humbled as I think of the responsibilities that could lie ahead," he said.
Initial counting had given Labor a marginal lead over Mr Abbott's coalition - but other results suggested heavy swings against Labor, in particular in the key states of Queensland and New South Wales.
Voting is compulsory in Australia, with 14 million registered voters.
Mr Abbott worked through the final night of the campaign.
Correspondents say he has tried to exploit the Labor party's divisions after the departure of Mr Rudd, trying to portray his coalition as a stable answer to a government beset by in-fighting.
In his campaign he has pledged to tighten immigration and has hit out at government spending. He has also toned down his well-known climate change scepticism.
Ms Gillard, a former lawyer who called a snap election shortly after coming to office, is hoping to be rewarded for the government's handling of the economy, which weathered the global recession remarkably well.
That Labor is locked into such a tight election race represents a turnaround in its fortunes since the start of the year.
Missteps by Kevin Rudd on climate change and a controversial mining tax caused his support - previously high - to fall sharply.
Ms Gillard won a leadership race in June but, despite her success, her support has fallen in the two months she has been in office.