Royal decree removes Mohammed bin Nayef as next in line to the throne and replaces him with Mohammed bin Salman.

Former Crown Prince Mohammed bin Nayef has pledged allegiance to his successor Mohammed bin Salman, the son of King Salman bin Abdulaziz.

A royal decree on Wednesday removed Crown Prince Mohammed bin Nayef, a 57-year-old nephew of the king, as next in line to the throne and replaced him with Mohammed bin Salman, 31, who was previously the deputy crown prince.

In televised images released by the state’s channel, Mohammed bin Salman, the former deputy crown prince, greeted his predecessor and said: “I will never give up your advice.”

The new crown prince was also named as deputy prime minister, and maintained his defence minister role.

King Salman called for royals to pledge allegiance to his son at the Safa Palace in Mecca after the Ramadan Taraweeh prayers.

The Saudi Press Agency reported that, in the interests of the country’s citizens, King Salman had already pledged allegiance to the new crown prince on behalf of the governors in the kingdom.

The king issued a decree last weekend restructuring Saudi Arabia’s system for prosecutions that stripped Mohammed bin Nayef of long-standing powers overseeing criminal investigations.

Instead the newly named Office of Public Prosecution and prosecutor will now report directly to the monarch.

Younger Saudis regard the ascent of Mohammed bin Salman as evidence that their generation is taking a central place in modernising and reforming a country whose patriarchal traditions have for decades made power the province of the older generations.

READ MORE: Saudis ‘reject’ Turkey offer to build base in kingdom

Mohammed bin Nayef, who is credited with putting down an al-Qaeda bombing campaign and establishing close ties with the United States, was also relieved of his role as interior minister.

He had taken over the formidable and effective security structure built by his father, the late Crown Prince Nayef.

The position was given to Mohammed bin Nayef’s nephew, 28-year-old law graduate Prince Abdul Aziz bin Saud.

The royal decree also included an extension of the Eid al-Fitr holiday by a week, from 10 to 17 days, to mark the occasion.

Mohammed bin Salman embarked on major overseas visits, including a trip to the White House to meet US President Donald Trump in March.

That visit to Washington helped to lay the foundation for Trump’s visit to Saudi Arabia in May, which marked the president’s first overseas visit.

Marwan Bishara, Al Jazeera’s senior political analyst, said this is the first time Saudi Arabia has such a young prospective king”.

“The king feels it is time to leave a legacy,” he said.

“The last two years the deputy crown prince has actually been leading while the crown prince was on the side,” Bishara added.

“It was just time to give him the official title.”