Polls have closed in New Zealand's general elections in what is being called the dirtiest campaign in the nation's history.
Until very recently PM John Key looked set to easily win a third term.
But in recent weeks he has been forced to defend his National Party against allegations of dirty politics and planning mass domestic surveillance.
Mr Key's personal popularity, however, remains strong among voters, polls show.
Nearly 3.5 million people were eligible to cast their vote. First results are expected in a few hours.
On Friday, a New Zealand Herald poll showed the National Party had 48% support. The main opposition Labour Party held 26%, with 11% for the Greens.
New Zealand's proportional representation electoral system means a coalition government is more likely than any one party winning a majority.
My Key might be forced to rely on New Zealand First's leader, Winston Peters, to form a government. Mr Peters, who has been in this position before, has not said which way his party will go.
Labour would need to form a coalition with the Greens, their old ally, New Zealand First and potentially the Internet-Mana Party which has been funded by Kim Dotcom, the online billionaire accused of copyright infringement in the US.
Mr Key, a former banker, campaigned on his strong economic track record and has pledged tax cuts.
Labour leader David Cunliffe promised to narrow the wealth gap through a capital gains tax and raising the minimum wage.
However, the main policy issues have been somewhat overshadowed by allegations in a book Dirty Politics that National used bloggers to smear opponents. It resulted in the resignation of Justice Minister Judith Collins.
Then Mr Dotcom held an event featuring Edward Snowden, the US National Security Agency whistleblower, and Wikileaks founder Julian Assange, who accused Mr Key of mass domestic spying.
However, Mr Key dismissed the allegations. "There's been all these distractions and different issues going on but the polling hasn't really moved," he told reporters on Friday. "There's just the natural tightening you get in any [campaign] cycle."
BBC/TF (Updated: 15:08)