BANGKOK - Thailand's King Bhumibol Adulyadej, the world's longest-reigning monarch, has died at the age of 88, the palace announced Thursday, leaving a divided nation bereft of a rare figure of unity.
Bhumibol's death ends a remarkable seven-decade reign and plunges Thailand into a deeply uncertain future.
Most Thais have known no other monarch and he has been portrayed as a guiding light through decades of political turmoil, coups and violent unrest.
"At 15:52 (0852 GMT, 4.52pm Singapore time) he died at Siriraj Hospital peacefully," the Royal Household Bureau said in a statement.
"Although the team of doctors treated him to the best of their ability, his condition deteriorated," it said as large crowds erupted in mourning outside the hospital where the monarch spent most of the last two years.
Prime Minister Prayut Chan-O-Cha, the former army chief who leads Thailand's ruling junta, said that the king's 64-year-old son, Crown Prince Maha Vajiralongkorn, is his named successor.
The Crown Prince is much less well known to Thais and has yet to attain his father's widespread popularity. He spends much of his time overseas, especially in Germany, and is a keen pilot who flies his own Boeing 737.
In a televised address to the nation, Prayut said Thailand would hold a one-year mourning period and that all entertainment functions must be "toned down" for a month.
PM Lee pays last respects to late Thai King in Bangkok
Thai television stations switched to a special announcement that began with black and white photographs of the king, before a formally dressed presenter read out the palace statement.
Bhumibol's death is a major test for the country's generals, who seized power in 2014 vowing to restore stability after a decade of political chaos, a turbulent period exacerbated by the king's declining health as jostling elites competed for power.
The military has deep links with the palace and many inside the kingdom saw the putsch as a move to ensure generals could stamp down on any instability during a succession.
It is difficult to overestimate how important Bhumibol has been to most of his subjects, who from cradle to grave have been taught about his devotion to his people in newspapers, history books and nightly television broadcasts.
Read also: World's longest-reigning monarchs
Backed by an intense palace-driven personality cult, he is revered as a demigod by many, seen as rising above the din of the kingdom's notoriously fractious political scene.
It is not unusual to see Thais moved to tears when they talk of a future without him.
Officially known as King Rama IX, he descended from the Chakri dynasty which came to power in Thailand in the late eighteenth century.
His subjects have had many years to get used to the prospect of no longer having Bhumibol - their king has not been seen in public for months and has suffered years of ill health.
A look back at Thailand's King Bhumibol Adulyadej's life
On Sunday and Wednesday the palace released two unusually grave health statements, saying the monarch was on a ventilator, battling kidney problems and that his condition was "not stable".
But his passing will still be a huge shock to the nation.
His reign spanned a remarkable era in which Thailand transformed itself from an impoverished, rural nation into one of the region's most successful economies, dodging the civil wars and communist takeovers of its neighbours.
He built a reputation for criss-crossing the nation to visit the rural poor and sometimes intervened to quell key moments of political violence - although other times he stayed silent and he approved most of the army's many coups during his reign.
Any criticism or effective republican sentiment has been erased inside Thailand by a draconian lese majeste law, use of which has surged since the military's latest takeover.
In recent years, and especially since the 2014 coup, the heir apparent Vajiralongkorn has made more frequent public appearances inside Thailand and taken on a larger number of royal engagements.
He will inherit one of the world's richest monarchies.
During his reign Bhumibol, with his establishment allies, built up a multi-billion-dollar-empire spanning property, construction and banks under the banner of the Crown Property Bureau (CPB).
Analysts say the CBP's vast reserves allowed the crown to build a deep network among the Thai elite, helping insulate the king from the political pressures felt by monarchs who rely chiefly on state funding.
The palace's announcement that the king was gravely ill sent shudders through the stock market and pushed the baht currency to a two-month low earlier this week.
"The death of Thailand's highly-revered king will plunge the country into a state of mourning, and also deep political uncertainty," Capital Economics said in a note.
"There is a risk that political tensions flare up, triggering a slowdown in economic growth," it said. "All eyes now will turn to the succession process."