BRUSSELS—NATO’s next boss is a political survivor who has said “no” to Donald Trump .

North Atlantic Treaty Organization members on Wednesday approved Dutch Prime Minister Mark Rutte to lead the 32-country alliance after current Secretary-General Jens Stoltenberg ’s term ends on Sept. 30th.

The decision, taken months later than many members had hoped, resolves an internal conflict just two weeks before allies gather in Washington for an annual summit that they hope will serve as a show of unity and strength. Some NATO officials had worried that a protracted leadership fight could undermine cohesion and overshadow other work, particularly in response to Russia.

“It was always a matter of when, not whether. So it’s good it’s done,” said former U.S. Ambassador to NATO Ivo Daalder. Since national leaders’ time is precious at a summit, he said, “you try to get as much done before, so that you leave the tough issues that only leaders can decide.”

Now NATO can plan an orderly transition from Stoltenberg’s decade in office. Members extended his initial four-year term four times , first for continuity amid rising tension with Russia and more recently because they couldn’t agree on a replacement.

“I know I am leaving NATO in good hands,” Stoltenberg said.

Rutte said he was honored by the appointment. NATO “is and will remain the cornerstone of our collective security,” he said.

Rutte will inherit an organization that has grown significantly—including the recent addition of Sweden and Finland —and transformed over recent years in response to Russia’s attacks on Ukraine, which started in 2014. Following Moscow’s full-scale invasion in 2022, NATO completely reworked its organizational structure and battle plans, reviving Cold War-era approaches to coalition fighting that had been shed in favor of expeditionary operations in Afghanistan and the Balkans.

Now it faces the challenge of beefing up and grappling with a sprawling, deadly war on its eastern border—and with continued U.S. support uncertain if Trump wins the Presidential race in November .

Trump has repeatedly criticized NATO and accused European members of not spending enough on defense and their own security. Other U.S. presidents have delivered the same message over recent decades, but Trump cast it more bluntly and implied he might pull the U.S. from NATO if Europeans didn’t step up.

European spending has risen since Trump’s presidency, though more in response to Russia’s invasion of Ukraine and threats to Europe than as a direct result of Trump’s attacks. This year for the first time more than two-thirds of NATO members will hit the alliance’s target of spending at least 2% of gross domestic product on defense—a fact the Biden administration is touting ahead of the summit, which is being held one week before the Republican national convention.

Rutte, who has been outspoken in support of Ukraine and against Russia, has led a push to boost Dutch military spending. Outlays are expected to hit 2.05% of GDP this year, compared with 1.66% last year, according to NATO data released last week.

Rutte is among Europe’s longest-serving leaders, holding office since 2010, through three subsequent elections and leading a variety of coalitions.

“He is a consensus builder, and that above all is the job of the secretary-general, who only has the powers of persuasion and leadership to move the alliance forward, not a vote,” said Daalder, who was born in the Netherlands and speaks Dutch.

Rutte played a central role in the Dutch government’s decision last year to block chip-equipment manufacturer ASML’s exports to China of some lithography systems, which are essential to making advanced microprocessors. The partial license revocation followed U.S. export restrictions and intense pressure from the Biden administration.

China, a growing security concern for NATO, is one of the few foreign-policy areas where President Biden and Trump are roughly aligned, so regardless of who inhabits the White House next year, relations with Beijing will remain high on Rutte’s agenda.

Rutte was prime minister during Trump’s presidency and met him several times, which means that if Trump is elected, NATO’s chief will have a degree of familiarity with the leader of the alliance’s largest and most powerful member.

At the White House in 2018, Rutte bluntly contradicted Trump regarding trans-Atlantic trade issues during an on-camera appearance, something few foreign politicians dared do.

Seated quietly next to Trump, Rutte listened as the president explained to reporters that a trade deal with the European Union would be good, but not agreeing a deal would also be positive.

“No,” Rutte said with a gentle laugh. “It’s not positive. We have to work something out.”

More recently, Rutte has also defended Trump’s calls for Europe to spend more on defense. Early this year he told Bloomberg Television that Trump “was completely right in forcing us to live up to the 2% commitment.”

Rutte proved himself adept at managing sometimes unwieldy coalition governments, shifting his party and government to the right during Europe’s migration crisis, keeping the economy stable during the financial crisis and managing for a decade to keep the Dutch far right out of power.

He gradually became equally adept at European politics, helping keep Brussels’ spending in check but working with other EU leaders to strike important deals, including a pact with Turkey to keep migrants out of the bloc and an $800 billion coronavirus recovery fund, which kept the EU’s economy running through the pandemic.

Critics have accused Rutte of ruthless opportunism, while supporters see him as a pragmatic dealmaker.

Rutte is chatty with the media and coins catchphrases. His comments often provoke headlines. He once told Hungarian Prime Minister Viktor Orban that if he didn’t like LGBTQ rights, he could take Hungary out of the EU.

An unmarried, childless workaholic, Rutte has eschewed a private life and relaxes by playing the piano and attending the opera, according to aides. He has long bicycled to work—a habit he may have to forego in the security-conscious world of NATO during a war in Europe.

When the Dutch hard-right party of Geert Wilders swept last November’s elections, after Rutte had already announced he would step down, concerns grew that Dutch support for Ukraine would wane.

Rutte, who has a close relationship with Ukrainian President Volodymyr Zelensky , has tried to assuage those fears, recently pointing to the coalition program of the incoming right-wing government to argue there would be no shift away from his foreign policy legacy.

“On Europe, on NATO, on Ukraine, nothing will change. That’s clear,” he said at a recent EU gathering.

Rutte becomes the fourth Dutch secretary-general in the alliance’s 75-year history—a record among member countries. He is the first Dutch secretary-general to have also served as prime minister, giving him valuable experience on the world stage. Both Stoltenberg, a Norwegian, and his predecessor, Anders Fogh Rasmussen , a Dane, had served as prime ministers, marking a shift from decades of ex-ministers of defense or foreign affairs in NATO’s top job.

Biden last year wanted Rutte for the job, according to people familiar with his thinking, but Rutte repeatedly said he didn’t want it. That changed a few months after last July, when the governing coalition he led collapsed.

Write to Daniel Michaels at Dan.Michaels@wsj.com and Laurence Norman at laurence.norman@wsj.com