WELLINGTON, New Zealand — After prolonged post-election negotiations in New Zealand, a minor party holding the balance of power threw its support behind the opposition Labour Party on Thursday, paving the way for 37-year-old Jacinda Ardern to lead the country.

If the parties involved vote to approve the deal, Ms. Ardern will take over from Prime Minister Bill English, whose center-right National Party has governed for nine years.

The announcement that a coalition had been formed came after a tumultuous campaign in which the National Party won 56 seats — more than any other party — but failed to capture the 61 needed for a parliamentary majority to govern in New Zealand’s political system.

In the Sept. 23 election, the center-left Labour Party won 46 seats, and its left-leaning allies the Greens won eight, giving the left bloc a total of 54.

The close result set off a scramble between the two groups to win the favor of New Zealand First, a populist party that won nine seats — enough to put either National, or the Greens and Labour, over the line in forming a government.

In the kingmaker position was New Zealand First’s leader, Winston Peters, an eccentric veteran politician who has long campaigned on cuts to immigration, curtailing foreign ownership of New Zealand land, and securing pensions and other benefits for retirees, who make up a large percentage of the party’s base of support.

While those issues were not at the forefront of political debate ahead of the election, they were thrust front and center after the vote as both major parties spent the week wooing Mr. Peters with policy proposals.

Mr. Peters, 72, has been in this position twice before: once in 1996, in a coalition with National that fell apart two years later, and in a coalition with Labour in 2005. He has a famously truculent relationship with the news media and remained tight-lipped throughout the coalition negotiation process, leaving analysts guessing whom he would anoint as prime minister.

Ms. Ardern took control of the Labour Party in July after its leader, Andrew Little, quit amid dismal poll numbers. She enjoyed a wave of attention for her charisma, for her youth, and for condemning a television commentator’s question about whether employers have a right to know whether a woman plans to become a parent.

During the campaign, she emphasized issues including child poverty, environmental management and housing affordability.

The campaign was raucous, at least by the standards of New Zealand, a prosperous member of the Commonwealth that has largely been spared the divisive debate over migration that has roiled its larger neighbor, Australia.

Mr. English, a former finance minister, had taken the reins of the country in December after his predecessor, John Key, unexpectedly resigned, citing a desire to spend more time with his family. During the campaign, Mr. English emphasized the party’s stewardship of the economy, which has recovered strongly from the financial crisis that was underway when the National Party swept to power in 2008.