Prince Nayef's body, which arrived earlier in the day in the city of Jeddah on board a Saudi aircraft from Geneva before being driven to Mecca, was wrapped in an ochre-coloured shroud during the ceremony and later buried in a cemetery next to the Grand Mosque.
Tributes for Nayef, Saudi's long-serving interior minister, poured in from around the world.
"Crown Prince Nayef devoted his life to promoting the security of Saudi Arabia," said UN Secretary General Ban Ki-moon, while US President Barack Obama praised his cooperation in the fight against terror that "saved countless American and Saudi lives."
French President Francois Hollande said his country had lost a "friend" and the president of the Swiss Confederation, where Nayef died, offered Bern's "deepest condolences."
Nayef's death, just eight months after he replaced his late brother Sultan as crown prince, raises the issue of succession because of the advanced age of the first line of apparent heirs, in a time of turmoil rocking the Arab world.
King Abdullah himself is 88 and ailing, and nobody is officially in line to replace Nayef.
His brother Prince Salman, 76, who took the defence portfolio after Sultan's death, appears to be a strong candidate.
"Prince Salman is the most likely successor," Saudi political scientist Khaled al-Dakheel said.
"All expectations point to Prince Salman to succeed Prince Nayef for his experience in administration, security and politics," agreed Anwar Eshqi, head of the Jeddah-based Middle East Centre for Strategic Studies.
-- 'Next in line --
And Jane Kinninmont, a senior research fellow for the Middle East and North Africa at London's Chatham House, said Salman is "generally assumed to be the next in line."
In 2006 the Saudi monarch established the allegiance council, a body of around 35 senior princes, as a new succession mechanism whose long-term aim was to choose the crown prince.
But the new commission had not been activated when Nayef was chosen as crown prince, according to Dakheel, who argued that naming his successor is a chance to bring the new body into play.
The royal decree that established the council postponed its use until after Abdullah's death.
"This is a chance to activate the allegiance council system... which provides a legal foundation for a peaceful power transfer within the family and leaves no room for surprises. This is important for state stability," Dakheel said.
Kinninmont argued that choosing the second in line to the throne, which is "likely to be signified informally by the title of second deputy prime minister, is more challenging."
King Abdullah did not name a second deputy after Nayef was promoted to first deputy after Sultan's death.
Nayef was the middle prince of the Sudairi Seven, the formidable bloc of sons of King Abdul Aziz by a favourite wife, Princess Hassa al-Sudairi.
In addition to Salman, remaining Sudairis include Prince Abdul Rahman, Prince Turki and Prince Ahmed, deputy interior minister and likely to succeed Nayef as the oil powerhouse's security chief.
Nayef, who spearheaded Saudi Arabia's clampdown on Al-Qaeda following a wave of attacks in the conservative kingdom between 2003 and 2006, became heir last October.
He forced the jihadist group's leaders and militants to flee to Yemen, from where they continue to be a thorn in the side of Saudi interests.
"He was one of the pillars of stability in the kingdom," wrote Al-Jazirah daily. "He managed to overcome crises and navigate this country to the shores of safety."
Prince Nayef travelled abroad several times this year for medical reasons, and was shown on television in Geneva three days ago greeting supporters.
The nature of his illness was not made public.
Seen as more conservative than King Abdullah, Prince Nayef was a staunch defender of the Saudi dynasty and resisted any opposition, especially from the Shiite minority in the eastern province.
He also strongly opposed allowing women to drive. A planned protest on Sunday by the Women2Drive group was postponed until Friday following Nayef's death.