Over the course of nearly five decades, Sultan Qaboos bin Said, who has died aged 79 after suffering from cancer, transformed Oman from a backward and isolated country into a prosperous, modern and unified state fully engaged in the Arab region and the wider world.

The longest serving Arab ruler, Qaboos was an absolute monarch, albeit a relatively benevolent and popular one. He came to power in a bloodless coup that overthrew his father, the increasingly erratic and repressive Sultan Said bin Taimur, in 1970. Despite denials at the time, the Sandhurst-trained Qaboos’s takeover was engineered by his British military advisers in order to avert the disintegration of the oldest independent Arab state (itself a former British protectorate) in the face of a communist insurgency in the southern region of Dhofar.

Within five years of Qaboos’s accession, the Dhofar uprising had been put down with the help of troops from Jordan and Iran as well as British special forces. The discovery of significant deposits of oil in the mid-1960s provided Qaboos with the opportunity to fulfil his promise to revitalise the lives of his people. At the time of his accession, Oman was a country plagued by poverty, illiteracy and disease, with life expectancy in the 40s. Slavery had yet to be abolished and the population was dependent on fishing and subsistence farming. There were only six miles of paved roads in the country. Slavery was outlawed as one of Qaboos’s first acts and today life expectancy is in the mid-70s and literacy rates are close to 90%.

Clinics, hospitals, schools and a sports arena, invariably named after the Omani ruler, almost entirely absent before 1970 are now commonplace across the kingdom.

Far less impressive was the extent of political change in Oman, where Qaboos retained personal control of all the main government posts and refused to delegate any real power to other members of a royal family that has ruled Oman continuously since 1749. Following unrest inspired by the Arab Spring in 2011, Qaboos removed several long- serving ministers perceived to be corrupt and widened the powers of a consultative council, but political parties and unauthorised public gatherings remained prohibited.

Even the US State Department – hardly Qaboos’s leading critic – drew attention to the raft of legislation that prohibited any criticism of the sultan and permitted the suppression of views deemed “politically objectionable”.

Born in Oman’s second city, Salalah, in Dhofar province, Qaboos was the only son of Said, who had come to power eight years previously, and his second wife, Mazoon al-Mashani. Qaboos was educated at a private school in Suffolk and worked briefly for Suffolk county council before entering the Royal Military Academy at Sandhurst at the age of 20. After graduating, Qaboos served a year in the British army in Germany. Returning to Oman in the mid-60s, Qaboos was excluded from any role in government by his increasingly troubled father; by the time of the coup that brought him to power in 1970 Qaboos was under virtual house arrest.

Qaboos’s accession had relied on British support though, as the new ruler, he soon moved to end the dependence on a British officer corps: by the end of the 70s, Omani officers commanded all infantry units. But this implied no break with Britain: Qaboos remained strongly attached to the UK and the British military. However there was a determined shift to a much more independent and pragmatic foreign policy, encapsulated in the phrase “friend to all, enemy to no one”.

In contrast to his father’s attempt to ignore the rest of the world, Qaboos set out to exploit the power implicit in Oman’s strategically important position at the mouth of the Gulf. Oman joined the Arab League and the United Nations and became a founding member of the Gulf Co-operation Council in 1981.

Qaboos established diplomatic relations with both the communist Soviet Union and China, allaying concerns in conservative circles by entering into close military cooperation with the US at the same time. While military ties with Britain remained firm, the relationship with Washington became of paramount importance: in 1991 Omani military facilities played an important role as a staging area for the movement of coalition troops against Iraq in the Gulf war. Qaboos sent Omani soldiers to fight in the US-led coalition. Access to Omani bases also played its part in the US-led invasion of Iraq to topple Saddam Hussein in 2003.

Qaboos also exhibited considerable skill in maintaining good relations with Iran, a potentially threatening presence across the Straits of Hormuz.

Despite his personal opposition to religious extremism and the close friendship he had enjoyed with the Shah of Iran, Qaboos considered it vital to have good relations with Iran’s Islamic rulers after the 1979 revolution. As a result, trade between Oman and Iran flourished and Oman became a consistent thread in stabilising relations between the Arab Gulf states and the Islamic Republic.

No less important was Qaboos’s role as a back-channel between Iran and the US, facilitating talks that led to the nuclear deal of 2015, since abandoned by President Donald Trump. The Omani leader also sought, with limited success, to mediate in the conflict in Yemen.

Even though Oman does not have diplomatic relations with Israel, its prime minister, Benjamin Netanyahu, visited Muscat in October 2018 to meet Qaboos – another sign of his resolve to have good relations with all.

A renowned patron of the arts, Qaboos created a symphony orchestra and opened a royal opera house in the capital, Muscat, in 2011. He was said to play the organ and the lute. He was also passionate about yachting.

His brief marriage to a first cousin ended in divorce in 1979. Qaboos has been succeeded by a cousin, Haitham bin Tariq al Said.

• Sultan Qaboos bin Said al-Said, sultan of Oman, born 18 November 1940; died 10 January 2020