BEIRUT, Lebanon — Even two steps away from the Saudi throne, Prince Mohammed bin Salman, the 31-year-old son of the king, had already pushed the titanic state oil company toward a public offering, loosened some social restrictions that rankled young people and waded into a costly war in Yemen with no plans for how to end it.

Now, Prince Mohammed stands to inherit a kingdom he has already shaken, after King Salman of Saudi Arabia named him crown prince on Wednesday. In doing so, the king swept aside his son’s older rival, Prince Mohammed bin Nayef, 57, upending decades of royal custom and profoundly reordering the kingdom’s inner power structure.

The move further empowers a young and ambitious leader while Saudi Arabia, a close American ally, is grappling with huge challenges, including low oil prices and intensifying hostilities both with Iran and in its own circle of Sunni Arab states.

In favoring his son over Prince Mohammed bin Nayef, who is respected for his security acumen, the king, who is 81, also marginalized a large cadre of older princes, many with foreign educations and decades of government experience that the younger prince lacks. If Prince Mohammed bin Salman does succeed his father, he could give Saudi Arabia what it has not seen in more than a half-century: a young king with the potential to rule for decades.