(CNN) New Zealand is to get its youngest-ever female Prime Minister after a minority party threw its support behind Labour leader Jacinda Ardern, who took over the left-wing party only three months ago.

Winston Peters, the leader of the anti-immigration NZ First party, announced in a live TV broadcast that he would support Ardern in a coalition government, after September's election returned a hung parliament

Ardern, 37, will become New Zealand's third female leader. Speaking after the announcement she said it was an "absolute honor and a privilege ... to form a government for all New Zealanders."

Ardern said Labour had found "true allies in parliament" -- NZ First and the Greens -- with whom a coalition could be formed to deliver the party's vision for the country.

The announcement ended almost a month of uncertainty, and weeks of negotiations, conducted by Peters with Ardern and the incumbent Prime Minister Bill English's National party over who could form the next government.

His decision was greeted with shock and elation in Labour Party headquarters, CNN affiliate Radio New Zealand reported. Peters did not tell Ardern or English who he would back before announcing it live on television.

"I joined with New Zealand as we collectively learned the news together," Ardern said, adding she "enjoyed the theater" of Peters' announcement.

'Labour believes in a Government that looks after its environment, and that looks after its people.' @jacindaardern — New Zealand Labour (@nzlabour) October 19, 2017

'Jacindamania'

Ardern will become New Zealand's third female prime minister, and the second-youngest, after Edward Stafford, who become Premier in 1856. He was also 37, but born later in the year. Ardern will be the youngest woman to lead the country.

A member of the Labour Party since she was 17 years old, Ardern became leader in August after her predecessor Andrew Little stepped aside at the start of the election campaign, when the party was struggling in the polls.

At the start of the year, English -- who replaced former National leader John Key in December -- was in a strong position and looked certain to continue Key's electoral success.

After she took over the Labour Party, Jacinda Ardern saw a huge boost in the polls, leading the press to coin the term "Jacindamania."

However, with "Jacindamania" came a surge in support for Labour, particularly among young people. The party polled just shy of 37% of the vote, enough to form a government with the support of NZ First and the Green Party.

When she was first elected, Ardern was the country's youngest sitting MP, and rose quickly through the party, becoming deputy leader in March this year.

A former DJ and a lapsed Mormon , Ardern is the closest thing New Zealand has had to a rockstar politician in years, attracting mass crowds to rallies and enjoying wall-to-wall press coverage.

While New Zealand has a parliamentary system -- where the prime minister is the leader of the governing party -- this election has been more presidential than ever, focusing on Ardern and English's personalities.

Not all that attention has been welcome. In her early days as leader, Ardern struck out against the media for focusing on her looks and questioning her about her ability to juggle the job with any potential future children -- criticized by commentators as a sexist double standard that would not be applied to men.

Winston Peters, leader of the New Zealand First party, speaks to the media outside Bowen House in Wellington on October 19, 2017.

Coalition negotiations

Speaking to reporters Thursday at the New Zealand Parliament, known as the Beehive, Peters was scant on details about the agreement with Ardern's party, but hinted he could become deputy prime minister.

The Labour-NZ First coalition will control 55 of the 120 seats in the country's parliament , meaning it will be dependent on the Green Party and its eight lawmakers to overcome the 61-seat threshold to pass policies.

The Greens later voted to endorse the deal put forward by Peters and Ardern, leader James Shaw told reporters.

Only around three of the party's 150 delegates voted against the deal, under which Green ministers will serve in government for the first time in the country's history.

"It is an historic moment for the Green Party and our movement," Shaw said, adding the new government has an opportunity to "make New Zealand a global leader in the fight against climate change."

However, despite having ministers in the government, the Greens will not be an official coalition party. Instead they will provide votes on a "confidence and supply" arrangement -- guaranteeing to support the government on major budgetary issues and votes of confidence.

Little said backing Labour was a vote "for change."

A vote for 'change'

Choosing to back Labour over National, which had been in government since 2008, was representative of the country's vote for "change," Peters said.

"All around the country people felt we could and should be doing far better," he said. "Too many people in the power structure in New Zealand are out of touch."

Praising Ardern's "extraordinary talent" in the campaign, Peters backed her pledge to build thousands of affordable homes per year.