Saudi Arabia’s new king swiftly moved to allay worries about continuity atop the oil kingdom, extending the line of succession to a younger generation by naming a nephew who has battled militant extremists and political dissidents alike.

On the same day he ascended to the throne, King Salman bin Abdulaziz appointed his 55-year-old nephew Prince Mohammed bin Nayef to the post of deputy crown prince, putting him second in line after Crown Prince Muqrin bin Abdulaziz.

After decades of the crown being passed from one son of the kingdom’s founder, Abdulaziz ibn Saud, to another, the decision to insert a grandson into the line of succession marked an important generational shift for the Saudi royal family and the country that bears its name. The move followed the death on Friday of one of Saudi Arabia’s most popular and longest-serving leaders, King Abdullah bin Abdulaziz.

Prince Mohammed bin Nayef is credited with dismantling al Qaeda in Saudi Arabia through an aggressive anti-terrorism policy that he led from 1999 under his father, a long-serving interior minister and later crown prince. Well before becoming interior minister himself in 2012, Prince Mohammed has been a central figure in the kingdom’s close relations with the U.S., and met in December in Washington with President Barack Obama .

“He’s an architect of the Saudi counterterrorism effort; he’s been the main point of contact for the U.S. on that,” a State Department official said.

James Smith, the U.S. ambassador to Saudi Arabia from 2009 to 2013, said the new king and deputy crown prince “might be the hardest working people I know in government,” and noted the Prince bin Nayef’s propensity to work long hours, often through the night.

“I asked him one time, ‘Why do you stay up all night?’” Mr. Smith said. “He smiled and said, ‘That’s when the bad guys come out.’”

The kingdom faces an array of challenges, and many of its critics have questioned whether its aging leadership has the energy and vision to tackle them. King Salman is 79 years old and Crown Prince Muqrin is 69.

The militants of Islamic State to its north have made clear the kingdom is on its list of hated targets, while a militia said to enjoy Iranian support has ousted the president of its southern neighbor on the Arabian Peninsula, Yemen.

“They’ve seen the rest of the Middle East unravel literally around them, and they’re determined not to let the Kingdom of Saudi Arabia be the next to unravel,” said Bruce Riedel, a senior fellow at the Brookings Institution. “They’ll work with the U.S. to prevent that, even as there’s going to be frictions on other issues.”

Saudi Arabia has become more aggressive in recent years in asserting its power in the Middle East. Even while it continues to see the U.S. as its ultimate protector, the kingdom has grown increasingly suspicious of Washington’s role in nuclear talks with Iran, which it views as a territorial and ideological rival.

But the U.S. and Saudi Arabia have long had issues on which they’ve agreed to disagree, including Israel.

“The fact that we may disagree on an issue or strategy does not in any sense mean there is a breach in the relationship,” Mr. Smith said.

State Department spokeswoman Jen Psaki said the U.S. and Saudi Arabia have a long history of working together. “We don’t have any indication that cooperation will change,” she said.

State television on Friday morning aired a brief speech by the new Saudi monarch in which he expressed sorrow over Abdullah’s death and affirmed that the kingdom would hold to the same “correct path” it has taken since its founding in 1932.

King Salman’s son, Prince Mohammed bin Salman, was named defense minister, a position the new king held until he succeeded his half-brother. The 34-year-old prince was also designated chief of the royal court, replacing Khaled Al Tuwaijri, who was removed from all his posts. Mr. Tuwaijri was an influential adviser to the late king.

All other current ministers in the cabinet, including the oil minister Ali al-Naimi, will keep their positions, King Salman said in another royal decree.

The path to royalty in Saudi Arabia, unlike most other monarchies, isn’t straight because the throne doesn’t pass automatically from parent to eldest child upon the death or abdication of the monarch.

Saudi law stipulates only that the throne passes to the “most upright” of the sons and grandsons of the kingdom’s founder.

The moves by Saudi Arabia’s new king came just hours before Abdullah’s surviving sons carried their father’s shrouded remains on a pallet atop their shoulders to his grave at Oud Cemetery in the capital, Riyadh.

In keeping with the traditions of the Wahhabi strand of Sunni Islam, which frowns on idolizing the dead and dramatic public expressions of grief, the grave was unmarked and members of the royal family and other mourners were somber and restrained.

In 2006, the Saudi royal family established a panel designed to help future kings choose their heirs, but exempted King Abdullah and his successor from its mandate.

Under the provisions of the so-called Allegiance Committee, any future king’s choice for crown prince will be subject to a vote by the panel, whose members are all from the royal family. If the committee disapproves of the king’s selection, it offers an alternative candidate. If the two sides still fail to agree, the committee votes on one of the two nominees.

Given the strength of royal prerogatives, however, it is far from certain whether the Allegiance Committee will be convened under any of King Salman’s successors.

Prince Mohammed bin Nayef has long been seen as a top contender to lead his generation into the Saudi succession.

A factor that set him apart from his peers among the founder’s grandsons is his having paid in blood for his country after a suicide bomber attempted to assassinate him in 2009. He survived the attack with minor injuries.

Under Prince Mohammed bin Nayef’s authority as interior minister, Saudi Arabia launched a sweeping crackdown on dissent that has intensified after the beginning of the Arab uprisings, with many human rights activists and critics of the government sentenced to travel bans and long jail terms.

Noted for his iron fist in cracking down on religious extremists and government critics, Prince Mohammed has also established rehab centers to lure extremists away from their ideology.

Prince Mohammed is also believed to have taken over the Syria policy after Prince Bandar bin Sultan was removed from his post as intelligence chief, and to be involved with Yemen policy, which is considered integral to Saudi counterterrorism effort.