* Now heir apparent, young prince might rule for decades
* In charge of defence, oil and economy
* Predecessor relieved of all posts
* U.S., Britain and Qatar congratulate Prince Mohammed
* Saudi royals and clerics pledge loyalty (Adds Saudis pledge allegiance)
DUBAI, June 21 (Reuters) - Saudi Arabia's King Salman made his son next in line to the throne on Wednesday, handing the 31-year-old sweeping powers as the kingdom seeks a radical overhaul of its oil-dependent economy and faces mounting tensions with regional rival Iran.
Although Mohammed bin Salman's promotion to crown prince had long been expected among those who follow the royal family closely, the timing was a surprise and puts the kingdom's future in relatively untested hands.
Mohammed bin Salman replaces his cousin, Prince Mohammed bin Nayef, a veteran security chief who led the Saudi campaign against Islamic State and al Qaeda, at a time when Riyadh faces tensions with Qatar and Iran and is locked into a war in Yemen.
His appointment may make Saudi policy more hawkish against arch-rival Iran and other Gulf rivals such as Qatar, increasing volatility in an already unstable region, analysts said.
"Under his watch, Saudi Arabia has developed aggressive foreign policies (Yemen, Qatar) and he has not been shy about making strong statements against Iran," said Olivier Jakob at Switzerland-based oil consultancy Petromatrix.
"It is not really a question of if, but rather of when, a new escalation with Iran starts."
U.S. President Donald Trump, who last month made Saudi Arabia his first foreign stop since his election, telephoned Mohammed bin Salman to congratulate him on his promotion.
"The two leaders discussed the priority of cutting off all support for terrorists and extremists, as well as how to resolve the ongoing dispute with Qatar," the White House said in a statement, adding they also discussed efforts to achieve a lasting peace between the Israelis and the Palestinians.
Qatar's Emir Sheikh Tamim bin Hamad al-Thani congratulated Prince Mohammed, in a conciliatory gesture to Riyadh after it joined other Arab states in imposing sanctions on Qatar over its alleged support for terrorism.
"His Highness (Sheikh Tamim) wished him success ... for the good of the kingdom under the wise leadership of the Custodian of the Two Holy Mosques," Sheikh Tamim said in a message to Prince Mohammed, Qatar state news agency QNA reported.
British Prime Minister Theresa May also welcomed Prince Mohammed's appointment.
Iran, Saudi Arabia's main rival for regional influence, called Prince Mohammed's appointment a "soft coup".
Its leadership was critical of comments he made last month that the "battle" should be taken into Iran, with Supreme Leader Ayatollah Ali Khamenei labelling Saudi leaders as "idiots".
Iran, which is predominantly Shi'ite Muslim, and Saudi Arabia, which is mostly Sunni, compete for power and influence across the region. The two countries support opposite sides in the conflicts in Syria and Yemen.
Analysts said the prince's rapid rise has created friction within the ruling family, however, and made Saudi policy less predictable than in recent decades.
Saudi royal family: http://tmsnrt.rs/2rVcsD4
The reshuffle sparked speculation on Twitter about a possible future abdication by the octogenarian King Salman bin Abdulaziz Al Saud in favour of his son, whose youth and dynamism have appealed to younger Saudis who make up the majority in society and are often eager for change.
After decades in which the same small group of princes handled Saudi affairs on the world stage, Prince Mohammed has led diplomacy with global powers, reportedly charming both Trump and Russian President Vladimir Putin.
He was appointed crown prince and deputy prime minister by royal decree, but he retains the defence portfolio and still controls oil and economic policies.
Mohammed bin Nayef, Salman's nephew and a counter-terrorism chief, who has been admired in Washington for crushing an al Qaeda bombing campaign in 2003-2006, was relieved of his posts, the decree said.
The decision by King Salman to promote his son and consolidate his power was endorsed by 31 of 34 members of the Allegiance Council, made up of senior members of the ruling Al Saud family, the decree said.
In a ceremony at a al-Safa palace in the Muslim holy city of Mecca late on Wednesday night, Saudi state television showed royal family members, clerics and officials queue to shake hands with the young prince or kiss his shoulder.
"We must hand in hand ... behind our leadership which we pray to God for it to be a wise one," Saudi Arabia's Grand Mufti Sheikh Abdulaziz Al al-Sheikh said, opening the pledging ceremony. "By God's book (the Koran) and the laws of His Messenger, I pledge allegiance."
Intent on dispelling speculation of internal divisions in the ruling dynasty, Saudi television repeatedly aired footage of Mohammed bin Nayef pledging allegiance to Mohammed bin Salman, who knelt and kissed his older cousin's hand, saying, "We will not give up taking your guidance and advice."
NO POWER STRUGGLE
Analysts said the change reduces uncertainty over succession and is expected to empower Mohammed bin Salman to move faster with his plan to reduce the kingdom's dependence on oil, which includes the partial privatisation of state oil company Aramco.
"The change is a huge boost to the economic reform programme ... Prince Mohammed bin Salman is its architect," said John Sfakianakis, director of the Gulf Research Centre.
Bernard Haykel, professor of Near Eastern Studies at Princeton, said the king's decision was aimed at avoiding a power struggle between his son and Mohammed bin Nayef.
"It's clearly a transition that has happened smoothly and bloodlessly. Now it's clear, it's straightforward. That kind of clarity lowers the risk. There's no question as to who's going to be in charge."
Saudi Arabia's stock market surged after the announcement, closing more than 5 percent up on the day.
Arab leaders, including Omans Sultan Qaboos, Jordans King Abdullah and Egypt's Abdel Fattah al-Sisi as well as Turkish President Tayyip Erdogan congratulated Prince Mohammed on his appointment, state media said.
The royal decree did not nominate a new deputy crown prince, a post relatively new in Saudi Arabia, where kings have traditionally chosen their own successors.
In an apparent attempt to appease the family, the decree had a clause that made clear that Mohammed bin Salman will not be allowed to appoint one of his own sons as his successor.
It also appointed young princes from other branches of the family to government roles, seemingly to reassure them that they will remain part of the ruling structure.
As deputy crown prince, Mohammed bin Salman has been responsible for running Saudi Arabia's war in Yemen, dictating an energy policy with global implications and spearheading plans for the kingdom to build an economic future after oil.
POWER BEHIND THE THRONE
Until his father became Saudi Arabia's seventh king in January 2015, few people outside the kingdom had heard of Prince Mohammed. As defence minister, he commands one of the world's biggest arms budgets and is ultimately responsible for Saudi Arabia's military adventure in Yemen.
Prince Mohammed chairs the supreme board of Aramco, making him the first royal family member to directly oversee the state oil company, long seen as the preserve of commoner technocrats.
But perhaps most importantly, he is the gatekeeper to his father, King Salman, who in Saudi Arabia's absolute monarchy retains the final say in any major decision of state.
Outside Saudi Arabia, that rapid rise and the sudden changes to longstanding policies on regional affairs, energy and its economy have prompted unease, adding an unpredictable edge to a kingdom that allies long regarded as a known quantity.
Inside, they have prompted admiration among many younger Saudis who regard his ascent as evidence that their generation is taking a central place in running a country whose patriarchal traditions have for decades made power the province of the old. (Additional reporting by Rania El Gamal, Sylvia Westall, Sami Aboudi, Andrew Torchia, Reem Shamseddine, Angus McDowall, Ali Abdelaty and Roberta Rampton; Editing by Samia Nakhoul, Hugh Lawson, Janet Lawrence, Toni Reinhold)