Saudi Arabia’s king has appointed his son Mohammed bin Salman as crown prince – replacing his nephew, Mohammed bin Nayef, as first in line to the throne.

King Salman’s decree also means Prince Mohammed bin Salman, 31, will become deputy prime minister while continuing as defence minister.

Prince Mohammed bin Nayef, 57, has also been removed from his role as head of domestic security, state media say.

He has pledged allegiance to the new crown prince, news agency SPA reports.

King Salman acceded to the throne in January 2015 after the death of his half-brother Abdullah bin Abdul Aziz.

Who is Mohammed bin Salman?

Saudi Arabia has typically been ruled by kings in their 70s or 80s.

Prince Mohammed bin Salman’s latest promotion, and his rapid ascent, is seen by the younger generation as a sign that things are changing.

He must have already ruffled a lot of feathers in a royal family that was used to being presided over by a succession of elderly men, the BBC’s Middle East editor Jeremy Bowen reports.

His father King Salman is 81 and reportedly not in the best of health, our correspondent adds.

Analysis by BBC Security Correspondent Frank Gardner

The rise of 31-year-old Prince Mohammed Bin Salman has been meteoric.

When I met him in Jeddah in 2013 he described himself as simply “a lawyer”. Today he is a heartbeat away from ruling the most powerful country in the Arab world.

Despite being the driving force behind Saudi Arabia’s damaging and inconclusive military campaign in Yemen, he is largely popular at home, especially with younger Saudis.

He has swept away many of the ineffective timeservers in government offices and replaced them with young, Western educated technocrats. He has set out a possibly over-ambitious development plan, “Vision 2030”, and announced plans to sell off part of the vast state-owned oil company, Saudi Aramco.

He has also forged ties with Washington and the Trump administration.

But his biggest and most risky move may yet prove to be his bid to curb the power of the conservative religious establishment. Washington likes this move, but others closer to home do not.

Media captionMohammed bin Nayef (R) pledged allegiance to Mohammed bin Salman (L), who knelt and kissed his older cousin’s hand

In addition to leading Saudi Arabia’s war in Yemen, Prince Mohammed bin Salman also oversaw the kingdom’s energy policy and was in charge of economic reform.

Meanwhile, Prince Mohammed bin Nayef was the kingdom’s security chief for many years and was known for his strong stance against jihadist militants.

He had headed up the counter-terrorism portfolio, and had good relations with Saudi Arabia’s Western allies, including the US and UK.