Abdurrahman Wahid studied in the Middle East, Europe and North America
Abdurrahman Wahid, who has died at the age of 69, was one of the most formidable and colourful figures in Indonesian political and religious life.
Wahid, or Gus Dur as he was also known, was born in Jombang, East Java in 1940, the first of five children in a prominent and politically active Muslim family.
His paternal grandfather was the founder of Indonesia's largest Muslim organisation, the Nahdlatul Ulama, or NU, while his father Wahid Hasyim would go on to be Indonesia's first minister of religious affairs.
The family moved to Jakarta in 1944 where Wahid attended school and was encouraged by his father to read non-Muslim books and newspapers to broaden his horizons.
He returned to Jombang to attend Muslim school in 1959, where he began work as a teacher and later as a headmaster, and in 1963 received a scholarship to study at al-Azhar University in Cairo, Egypt.
He continued his studies in the Iraqi capital Baghdad and later in the Netherlands, and eventually returned to Indonesia in 1971, where he worked as a journalist and social commentator, and later as an academic.
In the late 1970s Wahid began to play an active role in the running of the NU - which draws its support of at least 30 million members from Muslims in the rural areas of Java - seeing himself as a reformer of the organisation.
At this time he also had his first political experience, campaigning for the United Development Party, PPP, a Muslim party which was formed as a result of a merger of four Muslim parties including NU.
He became chairman of NU in 1984, but consistently maintained that government should be secular and that faith is a personal matter.
However his position as a moral leader was transformed following the dramatic fall of President Suharto in 1998.
Former president Wahid suffered poor health in recent years
In the ensuing unrest, some politicians made increasingly vocal calls for Islam to have an institutionalised role in the state.
Although health problems, especially poor eyesight, limited his effectiveness, Wahid's position as chairman of NU placed him in the role of "kingmaker" following Suharto's downfall.
Wahid and his supporters formed the National Awakening Party, PKB, and after months of prevarication over whether he would actually stand, Wahid was officially declared as presidential candidate in February 1999.
His election as president, in October 1999, came as a shock to many after Megawati Sukarnoputri's PDI-P party had emerged as the winner of Indonesia's parliamentary elections in June that year.
He was seen as a reformer and democrat as well as a man who could unite the country after the chaos surrounding the downfall of Suharto and his authoritarian regime.
Host of problems
But the transition to democracy was never going to be easy and President Wahid's honeymoon was short-lived.
He got off to a good start by curbing the influence of the military over his government.
Against great odds he succeeded in sacking the former armed forces chief and man accused of instigating the destruction of East Timor, General Wiranto.
He also moved early on issues such as the liberalisation of Chinese cultural and religious expression and the release of political prisoners.
He explored trade relations with Israel and agreed a memorandum of understanding, albeit briefly, with the separatist movement in the Sumatran province of Aceh.
But he soon ran into a host of problems, some of them self-made.
Despite a flare-up of sectarian and separatist violence across the country, Mr Wahid embarked on a series of long trips abroad, seeming to ignore problems back home.
His style of leadership soon appeared erratic and unfocused and in particular without any emphasis on the critical issue of economic recovery.
But perhaps his most controversial move was the sacking of two senior ministers from the cabinet without any proper explanation.
This also exposed the weakness of his coalition government as the main parties on whose support he depended began to turn against him.
Wahid's presidency ultimately collapsed following unproven allegations of corruption. One of the allegations involved the theft of $4.1m from the national food agency by people claiming to be acting on his behalf.
He was impeached by the Indonesian parliament in July 2001, and replaced by his deputy, Megawati Sukarnoputri.
Less than two years after his election, he was a politically isolated man, whose inability to govern rendered him an almost pathetic figure who refused to leave the palace despite being replaced by parliament.
In recent years he had suffered several strokes, kidney problems and was nearly blind.
He remained an influential figure in Indonesian politics, and a staunch defender of secular politics and moderate Islam.