Thailand was plunged into mourning Thursday with the death of King Bhumibol Adulyadej, the world’s longest-reigning monarch and the only ruler most Thais have ever known.

The death of Bhumibol — on the throne for seven decades — poses questions about the direction of the monarchy in the transition from a figure widely viewed as a near-deity.

Although the king has limited official power, the 88-year-old Bhumibol was seen as a unifying force in a nation that has faced coups and periods of crippling political unrest. At times, it took only a few words or gestures from Bhumibol to quell disputes or pull the nation back from crisis.

The Royal Palace said Bhumibol died “in a peaceful state” at Siriraj Hospital in Bangkok, where he had been treated for various health problems for years. His family, including his presumed heir, Crown Prince Vajiralongkorn, had been at his bedside in recent days as his health deteriorated.

Thailand’s King Bhumibol Adulyadej, who was the world’s longest-reigning monarch, died in a hospital Thursday, according to an announcement from the palace. (Reuters)

Moments after the announcement of his death, crowds gathered outside the hospital. People sobbed, hugged and collapsed into the arms of others. The throng grew by the hour, turning the compound into a sea of pink and yellow clothing, the colors of luck and royalty.

Chants of “Long live the king! Long live the king!” regularly broke out. Buddhist monks led prayers as well-wishers lit candles and fragrant joss sticks.

Others simply stared up, tears filling their eyes, at the hospital tower, across the Chao Phraya River from his palace, that had been the king’s home in recent months during his long illness.

The palace announced a year of official mourning at state agencies and government offices, with flags flying at half-staff for 30 days.

At Bangkok’s Erawan Shrine, where 20 people were killed in August 2015 in the city’s worst bombing attack, mourners placed offerings of garlands, fruit and joss sticks as they paid their respects to the monarch.

“This is a very sad day for our country,” said Piyanath Maneechot, an advertising executive. “He united us like a father. We really don’t know what will happen next to our country.”

Parithep Pongtong, 34, an events manager, was also anxious. “We have known nothing else but his rule,” he said. “He was a great leader, and we just don’t know what to expect for Thailand.”

And even as the late king’s subjects mourned, the succession process was, at least temporarily, muddied. For shortly after he was unveiled as the next monarch by the prime minister, Prince Vajiralongkorn declared that he did not want to assume the position immediately.

The national assembly had convened an emergency session that was initially expected to proclaim the prince as King Rama X. But the prime minister and junta chief, Gen. Prayuth Chan-ocha, disclosed that Vajiralongkorn was not yet ready to take the throne — a gesture of humility that may bolster his standing.

“He already accepted his appointment as a royal heir, but he requested time to deal with his grief and express his sadness alongside the people across the nation at this time,” Prayuth said. “As for the succession, he wishes to wait until the appropriate time.”

So the legislature’s session consisted solely of nine minutes of silence in honor of the late king — to the surprise of millions of ­viewers.

The late king’s body will be carried from the hospital on Friday afternoon to the Temple of the Emerald Buddha, next to the Grand Palace. There he will lie in state — a period expected to last 100 days — before the funeral rites.

Bhumibol had retreated from public life in recent years as his health declined, but his past outreach was known to nearly every Thai. He had pitched in at rice paddies in a symbolic show of solidarity with the country’s agricultural roots and had strongly encouraged Thailand’s rapid modernization since the 1960s. He played several musical instruments and once jammed with American jazz greats including Benny Goodman.

Bhumibol was born in Cambridge, Mass., on Dec. 5, 1927, making him the only king from any country born in the United States. His father, Prince Mahidol, was studying at Harvard Medical School at the time and died two years later of kidney and liver ailments. His mother was a Thai commoner.

In a televised address, Prayuth said that there would be no “festivities” for 30 days in a country whose economy is heavily dependent on tourist dollars.

If the succession goes as planned, Vajiralongkorn — the crown prince who has spent much of his time living with his entourage in Germany — will face the challenges of carving out his own identity as ruler amid political tensions.

The pro-royalist junta, which took power in 2014, has promised to hold elections by the end of next year after the passage of a new constitution that enshrines military influence in sectors of public life. But some analysts have predicted that the election timeline might slip into 2018 after a period of prolonged national mourning.

President Obama expressed “heartfelt condolences” and recalled meeting the king during a visit to Thailand in 2012.

Bhumibol “was a close friend of the United States and a valued partner of many U.S. presidents,” the White House statement said.

U.N. Secretary General Ban Ki-moon called the late king a “unifying national leader.”

Brian Murphy and Carol Morello in Washington contributed to this report.