New Zealand Prime Minister Helen Clark was poised to form an historic third successive government after her Labour Party clawed its way back past opposition National in a nail-biting election on Saturday.
Clark's Labour Party was just ahead after the close of counting late on Saturday but a number of possible outcomes remained after one of the closest elections in New Zealand's history, including a hung parliament.
"This election has been very finely balanced and the result has been a close one, and I'm humbled that we have the opportunity to begin negotiations to form a new government," Clark told jubilant party supporters.
However, days, perhaps weeks, of political horse-trading lay ahead as Clark and conservative National leader Don Brash hold talks with potential coalition partners among the six minor parties that won seats in parliament.
Clark remains as caretaker leader until a new government is sworn in. She would be the first Labour leader to head three successive governments.
When final counts were received from all polling stations by about midnight (1200 GMT), Labour had 40.7 percent of the vote compared with 39.6 percent for National.
That would translate into 50 seats for Labour in a 122-seat parliament, down just one from the previous parliament, compared with National's 49.
Former central bank governor Brash, a 64-year-old political novice, refused to concede defeat but did not appear to have enough potential coalition partners among the minor parties.
"We can't yet claim a victory but I'm certainly not conceding defeat," Brash said after his National Party almost doubled its vote from the 2002 election.
Both leaders spent a tense night at their home districts in Auckland, which was hit by a security scare when a man hijacked a light plane and threatened to crash it into the city's 328-metre (1,140-foot) Sky Tower.
The tower, on top of a large casino and hotel complex in the centre of New Zealand's biggest city, was evacuated. The plane later crashed into the harbour.
The pilot was rescued and taken to hospital, where he was being questioned by police, but his injuries were not life-threatening, local media said.
Brash had campaigned strongly during a rough-and-tumble campaign fought largely on local issues and his promises of NZ$9 billion ($6.4 billion) worth of personal income tax cuts over three years almost pushed him across the line.
Clark had trumpeted her record of stable government and economic growth averaging 4 percent over the past five years.
National opened a clear early lead in the counting after polls closed at 7:00 pm (0700 GMT) but Labour gradually clawed its way back as returns came in from urban centres such as Auckland and the capital, Wellington.
National's improved performance was achieved at the expense of other centre-right parties such as ACT with which it might have expected to form a coalition.
Labour could probably count on at least another seven seats from the Green and Progressive parties and, as the biggest single party, would look to United Future and New Zealand First to offer it support on key financial and confidence issues.
New Zealand First and United Future won a combined 10 seats, while even the fledgling Maori Party and its four seats could be called on by Labour.
However, after 2.05 million votes were counted on Saturday, another 193,000 "special" votes remained to be counted. These included absentee ballots and New Zealanders living overseas.