When Saudi Arabia’s elderly king took the unusual step of naming a deputy heir, the move initially was welcomed as a sign of continuity in a country that soon will confront major questions over the future of its leadership.

But in subsequent weeks, the announcement has stirred a rare outburst of dissent, revealing previously unacknowledged strains within the royal family and casting into doubt prospects for a smooth transition from King Abdullah’s rule.

The king’s youngest brother, Muqrin, who was named deputy crown prince on the eve of President Obama’s visit in March, appears to be popular among ordinary people, who say he is not corrupt. He also is well-regarded by foreign diplomats, who describe him as likable and smart.

But behind closed doors, royal tongues have been wagging about the manner in which Muqrin was chosen, the validity of his newly created title and his pedigree as the son of a Yemeni concubine who was never formally married to his father.

“He is not a real prince; his mother was a slave and there are other brothers who are more competent,” said a former Saudi official who spoke on the condition of anonymity because criticizing the royal family is imprudent. “Nobody believes Muqrin can become king.”

Some of the dismay has found a public airing on Twitter, which is better known in the Middle East for its role in fomenting social unrest but here also has found a niche as an outlet for disgruntled royals.

“He was picked for this post because he is easily used,” tweeted an account known as @mutjahidd, which has 1.4 million followers and is thought to belong to a palace insider because its information often is accurate.

The griping may merely reflect sour grapes among those left out in a looming transfer of power, or perhaps just the increased opportunities afforded by social media for tensions to come to light.

It has become clear, however, that Muqrin’s elevation is unpopular in at least some quarters, foreshadowing the strife that many fear will erupt as the older generation of the royal family passes away.

The controversy goes to the core of what is perhaps the biggest question hanging over the future stability of this family-run, oil-rich country, which does not have a clearly defined succession process in place.

The founder of the Saudi state, King Abdul Aziz ibn Saud, decreed only that his first son would inherit the throne, and over the subsequent six decades the succession passed from brother to brother roughly in order of their age. Soon, however, the last of the current line of brothers (of which there were at least 35) will die, necessitating a transfer of power to the brothers’ sons — the third generation of the family.

Given that there are scores of princes in that category, the potential for discord is high. Whoever inherits the throne is likely to anoint his own brothers as future heirs, thereby cutting out multiple cousins from access to the throne and the patronage it provides.

In light of Saudi Arabia’s strategic significance as the world’s biggest supplier of oil and a close ally of the United States, the succession dispute is of “considerable concern,” said Simon Henderson of the Washington Institute for Near East Policy.

“The identity and character of the future king is not known, and the circumstances under which he becomes king are likely to be contentious,” he said. “That introduces instability to Saudi Arabia.”

The issue also is growing in urgency as Abdullah enters his 90s. He breathed with the help of a respirator throughout his two-hour meeting with Obama in March, and he makes frequent visits to hospitals in the United States. His immediate successor, Crown Prince Salman, is hardly in better shape.

And so the choice of Muqrin, a British-educated fighter pilot who has close ties to the United States, had at least some logic. A relatively youthful 69, he could be king for years, deferring the tricky question of how to transition to the next generation. In light of the poor health of Salman, it would seem to make sense to have an heir in reserve.

But designating a successor is traditionally the prerogative of the reigning monarch, and the job of deputy has never existed before. Moreover, the naming of Muqrin skipped over at least two other brothers, upsetting the unspoken rule that the succession passes down according to age.

“What happened was against Islam and against the whole history of Saudi Arabia. There is no such thing as a deputy crown prince,” said the former Saudi official, who supports Ahmed, one of the older brothers, and hopes that Salman will revoke Muqrin’s appointment should he become king.

Theories abound as to why Abdullah made the move — all of them, like most of what transpires in this opaque and secretive kingdom, entirely speculative.

One, widely disseminated on Twitter, holds that Abdullah is seeking to secure the future of his own sons once the succession passes to the next generation. Muqrin, who lacks important tribal connections or an influential position, will be beholden, the theory goes, to Abdullah’s sons, notably his favorite, Mithab, who heads the national guard.

Another theory blames the powerful head of the royal court, Khaled Tuwairji, who is accused of duping the frail Abdullah into appointing Muqrin in return for a promise that he will keep his job after Abdullah dies.

“The sinister acts and destructive tendencies of this person are the cause,” tweeted Saud bin Saif al-Nasser, a prince whose father was passed over.

Western diplomats in Riyadh say the king may simply have been trying to secure the future of the monarchy but instead has exposed its vulnerabilities.

“Muqrin will potentially be the weakest king in Saudi history,“ said one, who spoke on the condition of anonymity because the subject is sensitive. “He is not from the first ranks of the royal family, he has no constituency and he will have to ride herd on a lot of powerful princes.”

Correction: This article has been amended to correct an earlier, unverified characterization of King Salman’s mental health. The article’s assertion that King Salman was “said to be suffering a form of dementia’’ was too speculative and unsubstantiated to meet The Post’s standards for publication. The Royal Court of Saudi Arabia, through its lawyers, has asserted to The Post that King Salman is “most certainly not suffering from dementia or any other kind of mental impairment.’’

Ahmed Ramadan in Beirut contributed to this report.