King Bhumibol Adulyadej, the constitutional monarch of Thailand for 70 years, who has died aged 88, played a crucial role early in his reign in nurturing and defending democracy at the expense of the country’s corrupt military elite. In later years, however, his reputation and that of the entire Thai royal family was endangered by identification with this same ruling clique in its power struggle against the unscrupulous but democratically elected government of Thaksin Shinawatra. Bhumibol was also criticised for failing to modernise the Thai monarchy, which still bestows semi-divine qualities on the king and imposes strict lèse-majesté laws to stifle any discussion of its behaviour or future role.

In 1973, he played a critical role in the overthrow of the dictatorship of Generals Thanom Kittikachorn and Praphas Charusathien, and on more than one occasion he defied military strongmen in order to promote a return to parliamentary rule. In 1992, when an impasse developed between a Thai general and his democratic opponent, the king went live on television with the two recalcitrants to bang their heads together. It was for this invaluable role in quietly protecting and promoting democratic rule that the educated elite of Thailand had a high regard for the king. He was also revered by the populace, especially for his charitable work.

Bhumibol’s rule began inauspiciously following the mysterious shooting of his elder brother, King Ananda, in June 1946. Such were the rumours at the time that Lord (Louis) Mountbatten advised Buckingham Palace not to allow Bhumibol to visit Britain as he was suspected of regicide. King George VI is reported to have remarked: “Buckingham Palace does not host murderers.”

There has never been any evidence that Bhumibol murdered his brother, though some speculated that Ananda’s death could have been an accident when the brothers were playing with firearms. The military dictatorship of General Luang Pibulsongkram, the Japanese collaborator, exploited the situation to blame the death on Pridi Banomyong, the pro-western former regent and prime minister at the time of the shooting. In 1947, he was forced to flee Thailand and was able to escape thanks to covert assistance from the British embassy. He went into permanent exile in China and France.

Facebook Twitter Pinterest King Bhumibol Adulyadej during his coronation in Bangkok, 1950. Photograph: EPA

Bhumibol was born in Cambridge, Massachusetts, the younger son of Prince Mahidol of Songkhla, himself one of the youngest of the former King Chulalongkorn’s 77 children from 92 consorts. Mahidol was something of a rebel who spent a good deal of time abroad. He was educated in Britain, at Harrow school, then at several German military academies, and finally at Harvard Medical School, in Boston, Massachusetts, where he specialised in public health. Mahidol’s wife was a Thai nurse, Sangwan Talapat, from a humble Sino-Thai family, which was always a sticking point with the grander inbred majority of the Thai royal family.

The family returned to Bangkok after Bhumibol’s birth, but Mahidol died two years later. Ananda became the heir presumptive to his uncle, King Prajadhipok, but a coup that resulted in the replacement in 1932 of absolute monarchy with a constitutional one prompted the family to emigrate to Lausanne, Switzerland, where they lived in relative obscurity.

Prajadhipok abdicated in 1935 and Ananda was proclaimed his successor but remained uncrowned and, with the exception of a brief family visit to Thailand in 1938, stayed in Switzerland. There were rumours of possible assassination plots even then. The royal children were educated at local schools in Lausanne until just after the second world war, when they returned to Bangkok on a special RAF flight.

Six months later, Ananda was shot dead. The new regent, Prince Rangsit of Chainat (yet another son of King Chulalongkorn), who had been appointed only the previous day, had been imprisoned by Pibulsongkram during the war, adding further speculation that the death was no accident. Bhumibol, who was only 18, accepted his new position as king, but returned to Switzerland two months later, ostensibly to continue his studies, but also to be out of harm’s way while various generals jostled for power.

While studying law and political science in Lausanne, he devoted considerable time to playing the saxophone and was involved in a car crash which caused him the loss of an eye. He also met his future bride, Sirikit Kitiyakara, the daughter of the Thai ambassador to Paris. Time magazine unfairly accused him of doing little else but “organise a swing band, tinker with cameras, drive fast cars”, though in fact the car he was driving at the time of his accident was a Fiat 500.

Bhumibol returned to Thailand for good in 1950, presiding over the long-delayed cremation ceremonies of his brother, marrying his fiancee and then getting himself crowned. He continued to have an uneasy relationship with the succession of military dictators who ruled Thailand, bolstered by huge funds acquired through prostitution, the heroin trade and the unswerving support of the US, which saw Thailand as a bulwark against the incipient communist insurgencies in neighbouring south-east Asian countries.

Facebook Twitter Pinterest King Bhumibol Adulyadej visiting northern Thailand for a royal project to help hill tribe people replace their opium crops with viable alternatives, 1969. Photograph: EPA

Although French and English were his first languages, Bhumibol quickly comprehended the power of ritual in Thai society: he played up his semi-divine status as monarch with the full panoply of court displays in the royal palace enclosure in Bangkok – one of the grandest in Asia. Bhumibol remained a politically isolated figure as the various dictators tried to undermine his credibility. He came close to being ousted in 1952, when he refused to endorse a new constitution, which placed more power in the hands of the military.

One of his closest friends was King Baudouin of Belgium, with whom he maintained a long and intimate correspondence. Baudouin’s most useful advice was for the king to stay out of direct politics and use his growing mass support to deal with his opponents. The biggest test of his authority came in 1973, when widespread unrest spearheaded by radical students finally threatened the military grip of Thanom and Praphas. Hundreds of thousands of students and citizens protested outside the royal palace, and dozens were gunned down by trigger-happy soldiers before the king finally convinced the ruling junta to leave Thailand, using his own radio transmitter, as he was denied access to the government station.

The leading student agitator at the time of the unrest later told me that at his audience with the king he ended each sentence formally with “dust under your feet”, until the exasperated monarch told him that such verbal deference was no longer required.

This experiment in democracy lasted only four years, after which the military once more had their candidate in power until a prime minister (albeit a former general) was democratically elected in 1988. Yet another general took power in 1992, but was quickly replaced when soldiers killed 60 people in street fighting. Throughout all of these developments, Bhumibol worked tirelessly to promote democratic government, although with varying degrees of success. One of the less attractive aspects of his rule was the general sycophancy shown to him by all ranks in society, which meant that several of his charities were often slightly harebrained.

Facebook Twitter Pinterest King Bhumibol Adulyadej and Queen Sirikit after reviewing an honour guard in Bangkok, 2005. Photograph: Sakchai Lalit/AP

One British ambassador recalled the expression of shock on courtiers’ faces when the Duke of Edinburgh gave Bhumibol his frank opinion about a royally approved scheme to extract petroleum from water. Nothing critical of the royal family is ever allowed to appear in Thailand.

It was often rumoured that Bhumibol was overly influenced by his wife, Queen Sirikit. Her attendance in 2008 at the cremation ceremonies for a protester against Thaksin’s government was seen as a dangerous display of partiality by the royal family. From 2009 Bhumibol suffered poor health, and for the last years of his life was hospitalised. In 2012 Queen Sirikit suffered a stroke.

There was never any whiff of scandal in the king’s private life, though that could not be said of his son, Crown Prince Vajiralongkorn. The little credibility the crown prince had was eroded in 2007 by the release of a home video shot in the royal palace showing his third wife, Princess Srirasmi, naked apart from a G-string, eating cake with Foo Foo, their poodle, who had been appointed an air chief marshal by the crown prince.

Bhumibol is survived by Queen Sirikit, Crown Prince Vajiralongkorn and three daughters, Princesses Ubolratana, Sirindhorn and Chulabhorn.

• Bhumibol Adulyadej, king of Thailand, born 5 December 1927; died 13 October 2016