King Salman’s decree also means Prince Mohammed bin Salman, 31, will become deputy prime minister while continuing as defence minister, according to the BBC.
Prince Mohammed bin Nayef, 57, has 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.
Prince Mohammed bin Salman’s rapid ascent is seen by the younger generation as a sign that things are changing.
Before his latest promotion, he was responsible for leading Saudi Arabia’s war in Yemen, overseeing the kingdom’s energy policy and economic reform.
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.
Prince Mohammed bin Salman could end up leading Saudi Arabia for decades.
The founder of Saudi Arabia, King Abdulaziz (known as Ibn Saud), had dozens of sons, and there are as many as 15,000 princes and princesses in the royal family.
In 2006, a decree was passed setting up a committee responsible for electing the king and crown prince. The committee is made up of senior princes of the Al Saud royal family and is known as the Allegiance Council.
Mohammed bin Salman’s new promotion to crown prince was approved by 31 out of 34 members of the council.
Analysts say those in power tend to appoint their sons to roles that will enhance their chances of being promoted – so when monarchs and crown princes change, sons can come into and out of favour.
King Salman acceded to the throne in January 2015 after the death of his half-brother Abdullah bin Abdul Aziz.
He launched his first major cabinet reshuffle a few months later, promoting Mohammed bin Nayef to crown prince and Mohammed bin Salman, who was relatively unknown at that time, to deputy crown prince.
Experts say the second reshuffle has reduced uncertainty over the line of succession, and means the king has averted a potential power struggle between his son and his nephew.
Saudi Arabia is the most influential Arab country – and a key ally of western powers including the US and the UK.
It’s guardian of the two most holy sites in Islam, and regards itself as leader of the Sunni community worldwide.
The kingdom is a key player in Sunni attempts to block Shia Iranian influence in the Middle East.
It is also the world’s leading oil producer – and the Saudi royal family is thought to be one of the richest ruling families in the world.
Prince Mohammed bin Nayef was the kingdom’s security chief for many years and was known for his strong stance against jihadist militants.
As deputy prime minister and interior minister, he headed up the counter-terrorism portfolio, and also had good relations with Saudi Arabia’s Western allies.
State media broadcast footage showing Mohammed bin Nayef meeting Mohammed bin Salman after the succession was announced.
The former crown prince said “I am content” and “I am going to rest now. May God help you”, while the new heir replied “May God help you. I will never do without your advice”.