A fluent English speaker who was educated in the United States and worked abroad for years, Mr. 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 working to end Libya’s status as an international pariah.
His plans were often blocked by an old guard opposed to reform and by a system in which the interests of the Gaddafi family came before those of the state.
Mr. Ghanem was pushed out of the prime minister’s job, and in later years he talked often of giving up public life. But he did not make a final break with the Gaddafi administration until the end of May last year, after opponents had risen up against the Libyan leader.
Mr. Ghanem appeared in Rome and told reporters that he had defected because of the “unbearable violence” being used by Gaddafi’s forces to try to put down the rebellion.
By then, though, Mr. Ghanem was so closely associated with Gaddafi’s rule that the rebellion snubbed him, and he died in exile, harried by allegations of corruption that came to the surface after Gaddafi’s rule ended.
Mr. Ghanem graduated in English from Benghazi University, in eastern Libya. 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.
During his period at OPEC, Mr. Ghanem forged 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 Mr. 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 started to push a reform agenda. He recommended to his father that he bring Mr. Ghanem back from Vienna and appoint him as economy minister.
Mr. 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 People’s 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.
But by 2006, Mr. Ghanem had annoyed too many people in the old guard. Gaddafi called him into the Bedouin tent where he liked to hold meetings and told Mr. Ghanem that he was being moved to the chairmanship of the NOC. In his new role, Mr. Ghanem oversaw the return of foreign oil companies to Libya after decades of isolation.
But Mr. 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 Mr. Ghanem’s, said the NOC chief had lost faith in the prospects for reform. A year later, he was replaced as NOC chief. Weeks afterward, he was back at his post.
When the revolt broke out in February last year, people who knew Mr. 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 that he planned to defect. A few weeks after that, Mr. Ghanem applied for permission to leave Libya so he could go to Vienna for business. It was a pretext for traveling to Rome to announce his defection.
According to someone close to the former Libyan leader, Gaddafi granted permission because he did not believe someone as loyal as Mr. Ghanem would defect.
After leaving Libya, Mr. 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 Mr. 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, he related grisly stories 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.