ZAWIYA, Libya | During Libya's revolution, as the rebels pushed toward this strategic oil town outside of Tripoli, government forces retreated to one of their most precious remaining assets - the Zawiya refinery.
Zawiya refined gasoline throughout the conflict, only pausing briefly when the rebels arrived at its gates. Mohammed Zotto, 55, was one of a handful of supervisors who remained to ensure the tanks, full of hydrocarbons, didn't blow up.
"I was afraid, but more for the refinery than my life. I am here 35 years," Zotto said.
Zawiya's twin refineries survived the war and today are running at full capacity, turning light crude into 120,000 barrels of oil products per day and employing about 2,300 Libyan workers.
Defying both doomsday scenarios and even modest recovery projections, Libya's oil industry is now booming. It is one the few examples of national success as Libyans head to the polls to vote in their first free elections since the fall and death of former Libyan strongman Muammar Gaddafi.
The country, upended by the revolution and sudden absence of Gaddafi's iron-fisted rule, remains plagued by divisions and violence. But perhaps owing to the foresight of both the Gaddafi regime and the opposition, and their understanding that Libya's economy is almost entirely dependent on oil, the oil fields were protected, allowing the industry to recover quickly.
"There was no severe damage to oil fields," said Deputy Oil Minister Omar Shakmak in an interview with GlobalPost at his office in Tripoli. "The Zawiya refinery started Sept. 25. From the first week it was running at 100 percent capacity."
Many Libyans remember when Saif al-Islam, Gaddafi's son, warned at the outset of the rebellion that a civil war would lead to a collapse of the Libyan oil sector, and the country's long-term economic health.
"Brothers, there are $200 billion of projects at stake now," he said on state television at the time.
Oil workers feared the worst.
"I was thinking it could happen like in Kuwait," said Musa Ahmed, the acting production manager for Libya's National Oil Company. "Oil wells could burn ... I expected it to take not less than two years to rebuild."
Instead, Libya is already producing 1.5 million barrels of oil per day, just shy of pre-revolution numbers. More and more foreign investors, encouraged by the upcoming elections and the country's ability to get oil production back on track so fast, are now coming back to Libya.
Libya's wells produce what is known as light, sweet crude, which has a low sulfur content and is therefore easier to refine into gasoline and other oil products. It is favored in European markets because of Libya's proximity. Libya owns Africa's largest proven reserves, about 46 billion barrels, and some experts believe only 30 percent of the country has been explored.
The country is still a long way from its oil heyday, in the 1960s, when the oil-rich Sirte basin produced 3.5 million barrels per day. Nationalization of the oil sector, and western embargos levied against the Gaddafi regime, forced production down to 1.5 million barrels per day over the following three decades.
But in 2012, with the global price of oil surging and the average cost of producing a Libyan barrel decreasing, Libyan officials expect significant profits. And they have set an ambitious goal of producing more than 2.5 million barrels a day by 2013.
To reach that goal, however, they say they are going to need more international investment, something that will only come with more security and political stability.
Foreign energy companies have so far met with mixed results in post-Gaddafi Libya.
Most international oil companies shuttered their operations during the revolution, leaving behind skeleton crews of locals to keep the pumps primed. Many facilities gathered dust.
But as production ramped up after the war, European oil companies with big stakes quickly returned and new players began finding ways to capitalize on a more open market.
The largest foreign oil company operating in Libya, Eni, an Italian multinational, signed a memorandum with the country's transitional council at the end of May 2011 to provide petroleum during the crisis. As soon as major hostilities ceased in August 2011, Eni CEO Paolo Scaroni flew to Tripoli to meet with top officials. Eni then quickly moved to re-start production at 15 Libyan wells, and re-opened its most important project - a 340-mile long Greenstream pipeline to Sicily.
Italy is the largest importer of Libyan oil, accounting for about 32 percent of the total.
Today, because of its close connection to the country's leadership, Eni's production in Libya is almost back to pre-revolution levels.
Foreign companies, however, are still concerned about security, and have been slower to return than expected. Many of the estimated 4,000 expats in the oil sector before the war have yet to come back, officials say. And some of those who did return have faced major hurdles.
Last October, Halliburton's country manager had to leave Libya after Libyan workers protested for higher wages, according to a Middle East oil sector consultant interviewed by GlobalPost.
Many Libyans are demanding foreign oil companies do more for the social welfare of the people who live on the land they are using.
"Oil companies have been here decades, but have spent nothing," said Mohamed Bashir, an activist and advisor to the transitional government. He said the new government should demand more from the foreign oil companies.
But perhaps the biggest reason why foreign oil companies have been slower to return is a lack of security. Most of Libya's security is still performed by former revolutionary militias, which operate in tandem but not always under the control of the government.
"Expats and officials want uniformed security," one oil executive, who declined to be named, told GlobalPost.
Corruption also remains a pervasive problem in Libya, and a threat to oil production and contracts. As the popular saying goes here: "If we took out all those involved in corruption, there would be no more Libya."
Officials at the Ministry of Oil have said they will not nationalize the oil industry, allaying some fears among foreign investors. But at the same time, to allay fears of revolutionary Libyans, the ministry has promised to review old contracts.
How the new government will evaluate those old agreements remains unclear. Some officials say that countries like Italy and France, who were among the first to support the Libyan revolution, should be favored.
"It's logical to treat a friend as a friend," said Wanis Elruemi, who has helped negotiate oil contracts in Libya for decades.
National Oil Company's acting production manager, Musa Ahmed, agreed. "All the countries who stood beside Libyans during the war should have a chance. I feel not happy with Russia and China."
Such resentment might not last long, however. China is quickly becoming one of the biggest importers of Libyan oil, accounting for about 10 percent of the total over the last year.
Above all, it will be political stability that brings foreign investment and oil revenue back to Libya. And that stability begins with elections this weekend.