TRIPOLI Shokri Ghanem, Libya's former prime minister and oil chief, saw it as his mission to change his country from the inside, only to realize too late that Muammar Gaddafi would never accept any meaningful reform.
Ghanem died in Vienna, at the age of 69, a spokesman for the Austrian foreign ministry said on Sunday.
A fluent English speaker who was educated in the United States and worked abroad for years, Ghanem was one of the main reforming influences inside the Libyan administration for the past decade.
First as prime minister and later as de facto oil minister, he played a central role - often alongside the Libyan leader's reform-minded son Saif al-Islam - in ending Libya's status as international pariah and opening it up to Western investment.
His plans were often blocked by an old guard opposed to reform, and by a system where the interests of the Gaddafi family came before the state.
Ghanem was pushed out of the prime minister's job by the old guard, and in later years, frustrated and discouraged, talked often of giving up public life.
But he never did make a final break with the Gaddafi administration until the end of May last year, after opponents had risen up against the Libyan leader and begun a rebellion.
Ghanem appeared in Rome, and told reporters he had defected because of the "unbearable violence" being used by Gaddafi's forces to try to put down the rebellion.
By then though, he was so closely associated with Gaddafi's rule that the rebellion snubbed him, and he died in exile, harried by allegations of corruption against him that came to the surface after Gaddafi's rule ended.
Ghanem graduated in English from Benghazi University, in eastern Libya, and his first job was as head of the translation unit with the state news agency. He later studied for a PhD at Tufts University in the United States.
Back home, he worked at the National Oil Corporation (NOC) and then found a job in Vienna in the Secretariat of the Organization of the Petroleum Exporting Countries (OPEC). He worked his way up to be OPEC's head of research.
It was during his period at OPEC that Ghanem was to forge the relationship that would shape the rest of his career and his role in Libya's political life.
Saif al-Islam Gaddafi arrived in Vienna in the late 1990s to study for an MBA. He sought out Ghanem and they became friends. The OPEC official helped the younger Gaddafi with his studies, and some of his liberal thinking also rubbed off.
Back home in Tripoli, Saif al-Islam was starting to push a reform agenda. He recommended to his father that he bring Ghanem back from Vienna and appoint him as economy minister.
Ghanem returned home in 2001 to take up the new job and two years later, again after lobbying from Saif al-Islam, he became Secretary of the General Peoples' Committee, de facto prime minister.
In that post he started breaking up Libya's Socialist-style economic system. He ended subsidies on food, got rid of some restrictions and began a program of privatization. In parallel, Saif al-Islam was helping negotiate the lifting of international sanctions on Libya.
But by 2006, Ghanem had annoyed too many people in the old guard. Gaddafi called him into the Bedouin tent where he liked to hold meetings, and - without informing Saif al-Islam - told Ghanem he was being moved to the chairmanship of the NOC.
In his new role, Ghanem oversaw the return of foreign oil companies to Libya after decades of isolation. One source in the NOC who knew Ghanem at this time told Reuters: "He was very authoritative, very strong-minded and tough with his employees."
"Some people were even afraid of going to his office. You would hear of people being fired if they challenged him. He was like a small Gaddafi of the oil sector."
Other people saw a charming, jovial face.
As head of his country's delegation to OPEC, Ghanem would often return to Vienna for meetings. There, he would invite foreign journalists up to his suite in the InterContinental Hotel for interviews.
At other times, he would ring up selected journalists and, between jokes and peels of laughter, would give them information that often moved oil markets.
"He was a very good friend and did a good job for his country and OPEC," said Chakib Khalil, a former oil minister in Libya's neighbor, Algeria.
But Ghanem was struggling in the swirl of intrigue and plotting that made up the Gaddafi administration, especially when Saif al-Islam was not around to support him.
A leaked U.S. cable from 2008, citing a friend of Ghanem's, said the NOC chief had lost faith in the prospects for reform and was fed up with some of Gaddafi's other sons using the NOC as a "personal bank".
A year later, during another turf war between the old guard and reformers, he was replaced as NOC chief. Weeks afterwards, he was back at his post. He told diplomats he had used the time to "catch up on movies, read books and rest".
For several years he would tell friends or trusted journalists that he wanted to quit or retire, but he stayed on.
When the revolt broke out in February last year, people who know Ghanem said he was unhappy about the violence being used by Gaddafi's security forces. They said he stuck to the party line while he worked to get his family out of the country.
In a March 2 interview with Reuters in Tripoli, he denied he planned to defect. "You see me, I am in my office," he said.
A few weeks after that, Ghanem applied for permission to leave Libya so he could go to Vienna for business. It was a pretext for travelling to Rome to announce his defection.
The travel request was passed to Gaddafi. According to someone close to the former Libyan leader, he granted permission, because he did not believe someone as loyal as Ghanem would defect.
After leaving Libya, Ghanem settled back in Vienna, where he had an apartment and where one of his daughters lives.
By the end of last year, Gaddafi was dead and files had surfaced implicating Ghanem in corruption in the oil industry. He denied wrongdoing, and said people were inventing stories about him "for personal revenge."
In a meeting with a Reuters journalist in December last year in a Viennese hotel near his apartment, he was upbeat as usual but complained about the potential costs of having to fight any legal battle over the corruption allegations.
He also related grisly stories he had heard about the torture he said had been meted out in Libya to Gaddafi-era officials arrested by the former rebels now running the country. For this reason, he said, he could not go back home.
(Additional reporting by Alex Lawler in London and Michael Shields in Vienna; Writing by Christian Lowe Editing by Maria Golovnina)