WELLINGTON, New Zealand — In a push to counter the popularity and charisma of Prime Minister Jacinda Ardern, New Zealand’s main opposition party elected a young lawmaker as its new leader on Tuesday.

The vote, held behind closed doors by the lawmakers of the center-right National Party, follows the resignation of the party’s longtime leader, Bill English, after the elections of September 2017. The party failed to win a parliamentary majority, and a coalition led by Ms. Ardern’s center-left Labour Party formed the government.

The new opposition leader, Simon Bridges, the youngest of the contenders at 41, billed himself as the candidate offering a “generational change.” Five lawmakers ran for the post to lead the National Party’s 56 members in Parliament.

Paula Bennett will retain her role as deputy leader.

Mr. Bridges, a former prosecutor who cited his “young family” in interviews ahead of the vote, will now lead the effort to defeat Ms. Ardern, 37, in New Zealand’s 2020 election.