Rabat - King Hassan of Morocco died on Friday shortly after being admitted to hospital.
Crown Prince Sidi Mohammed, 36, who will succeed him as leader of the North African country of 29 million people, said his father died of a heart attack.
King Hassan, 70, had ruled for more than 38 years. He once told his friend King Juan Carlos of Spain: "When I ascended the throne, people said I would not last more than six months."
Moroccan state-run television RTM interrupted its programmes to read verses from the Koran.
Earlier, the official MAP news agency quoted a royal palace statement as saying, "The Royal Palace medical staff announced that His Majesty King Hassan was admitted today to Avicennes hospital in Rabat due to the appearance of an acute pneumonia."
King Hassan had been in poor health for several years and was stricken by pneumonia while on a visit to the United States in November 1995 amid reports that he was seriously ill.
His last appearance on public television was on Wednesday when he met Yemen's President Ali Abdullah Saleh.
It was not immediately known when the king's funeral would held.
Born on July 9, 1929, King Hassan had two sons and three daughters by Lalla Latifa, a commoner styled simply as the mother of the royal children. His heir, Crown Prince Sidi Mohammed, who was born in August 1963, is unmarried.
Former US ambassador Marc Ginsburg, who ended his term in Morocco last year, said of King Hassan: "Not only has Morocco lost a truly great leader, the world and the Middle East in particular has lost a great leader."
Earlier this month, the king paid a three-day official visit to France, meeting President Jacques Chirac and Prime Minister Lionel Jospin.
The king, the longest-serving monarch in the Arab world who was more than 38 years on the throne, celebrated his 70th birthday on July 9.
He survived two attempted coups by military rebels, in 1971 and 1972, and ruthlessly crushed those involved.
His opponents accused him of human rights abuses.
Although the palace denied that Morocco had political prisoners, he responded to critics in the early 1990s by ordering the release of left-wing opponents and members of the military who had sought to overthrow him.
More than 800 such prisoners were freed.
Seen as a staunch supporter of the West, King Hassan long worked secretly for Middle East peace and played a leading role in getting the 1991 Madrid peace conference held.
But he twice refused to meet Israel's right-wing former prime minister Benjamin Netanyahu, who was ousted from office earlier this year by Ehud Barak.
Another former Israeli prime minister, Shimon Peres, paid tribute to the king, saying, "I'm really shocked and I feel a deep loss. He had the wisdom of trying to navigate a difficult situation. He was a highly sophisticated man. He was a man of great warmth and personal involvement.
"He was a real friend of the Jewish people. He hoped for peace, he dreamed of peace and he fought for peace."
In his efforts to forge warmer links in north Africa, the king was also planning to meet Algerian President Abdelaziz Bouteflika in the next few weeks, Algerian officials said.
It would have been the first meeting between the heads of state of the two countries whose relations have long been strained over the Western Sahara.
Ties between the two north African neighbours worsened in 1994 after an attack on a Moroccan hotel by gunmen of Algeria, and which led to Algeria closing its land borders after Rabat established entry visas for Algerians.
Both countries were members of the Arab Maghreb Union, set up in 1989 to try - with Tunisia, Libya and Mauritania - to form an economic bloc.
Efforts to achieve this were largely stymied over violence in Algeria, political rivalries and the Western Sahara dispute. Morocco claimed sovereignty of the former Spanish territory while Algeria supported independence-seeking Polisario guerrillas.
The king also pushed to try to bring opposition into government and last year appointed Socialist veteran Abderrahmane El Youssoufi as prime minister, achieving a long-held vision of greater unity in his country. - Reuters