A decade ago, Canada’s oil sector was predicted to become a global energy superpower, but a series of political missteps and formidable environmental activism created a dysfunctional system requiring OPEC-style government intervention to move its oil to market.

Canada produces 4.9 million barrels of oil per day (bpd), more than any country other than the United States, Saudi Arabia and Russia. But the world’s fourth largest producer has had to nationalize a pipeline and the province of Alberta is exploring buying trains to handle a glut of oil sitting in storage.

Canada’s crisis coincides with big producers taking market share away from OPEC members, mostly clustered in the Middle East. Global oil demand is expected to surpass 100 million bpd in 2019. The United States has driven exports to record highs on growing demand from China, India and other developing countries.

But Ottawa has failed under two governments to effectively counter the strategy of environmental activists to attack the oil sector’s heart by choking its arteries – pipelines. Roughly 35 million barrels, twice the normal amount, of Western Canadian crude used to produce diesel, gasoline and jet fuel is stuck in storage.

The energy sector accounts for nearly 11 percent of Canada’s gross domestic product. However, Canadian oil trades at a fraction of global prices, costing the economy C$80 million per day, according to the Alberta provincial government.

Alberta has taken the unusual step of temporarily curtailing 325,000 bpd from January – in the aftermath of a retreat from the oil sands by global companies including ConocoPhillips and Statoil.

“It’s become dire now because the writing is clearly on the wall. The issue is market access,” Jihad Traya, manager of energy advisory service HSB Solomon, told Reuters.

Prime Minister Justin Trudeau’s government, facing an election this year, has offered the oilpatch C$1.6 billion in aid. In May, Ottawa agreed to buy the Trans Mountain pipeline in hopes of pushing through an expansion to nearly triple capacity as other proposed lines languished.

Back in 2006, then-Prime Minister Stephen Harper boasted Canada would soon become an “energy superpower.” Canada was producing 2.6 million bpd, which moved smoothly to US refineries through pipelines. Since then, production has nearly doubled, but pipeline growth has stalled.

Both Conservative Harper and Liberal Trudeau squelched opportunities to complete pipelines just as opposition to more lines multiplied. Two projects were killed, and legal setbacks have stymied the development of TransCanada Corp’s Keystone XL and the government-owned Trans Mountain expansion.

A year after taking office in 2015 Trudeau proposed a bargain aimed at satisfying both environmentalists and the oil industry – a national carbon-pricing plan to reduce Canada’s emissions while approving pipeline expansions.

The strategy has inflamed both sides.

When a court overturned Ottawa’s approval of the expansion of Trans Mountain in August, the deal was off and Alberta Premier Rachel Notley yanked support for Trudeau’s carbon plan just hours later.

Indigenous and environmental opposition to pipelines has forced Trudeau to push for tighter regulations on future pipelines. The changes are necessary to “depoliticize” the system, Natural Resources Minister Amarjeet Sohi said.

“We need to fix the broken system that we have now so we are able to build the pipeline capacity that is so necessary.”

But Trudeau has already shelved Enbridge’s Northern Gateway proposal, which would have run through northern Alberta to the Pacific coast, and the National Energy Board in 2017 toughened its review of TransCanada’s Energy East pipeline while it was underway.

Both projects are now dead. Alberta is seeking to buy rail cars to reduce the glut, and last month, the province ordered producers to cut output after its oil fell to a discount of $52 per barrel from US oil in October.

Notley told reporters before the New Year that people in Alberta can make profits from oil and gas, “but they need Ottawa to take the handcuffs off. We need rail. We need long-term support for getting that pipeline built.”

Alberta’s oil sands, a mixture of sand, water, clay and thick, heavy oil, became a compelling target for environmentalists as production expanded dramatically in the early 2000s.

Clayton Thomas-Muller, an indigenous activist, said environmentalists grew frustrated trying to stop the industry’s expansion through the Alberta Energy Regulator, but found a new strategy of opposing the pipelines.

They built wider coalitions, tapping into anger of Nebraska ranchers and drawing the attention of Hollywood celebrities such as director James Cameron.

Opponents of TransCanada’s Keystone XL began protests at the White House in 2011, seeking arrest and attention. Then-US President Barack Obama finally rejected the project in 2015.

“Full credit to climate-change advocates, they kicked the snot out of Corporate Canada,” said Tim Powers, a Conservative political strategist. He told Reuters that Canadian resource companies have been too focused on the regulatory process, while climate-change advocates “laid out a better, more compelling narrative” to win public opinion.

US President Donald Trump resurrected Keystone XL in 2017. But both KXL and Trans Mountain remain in regulatory limbo after courts ruled in recent months that the US and Canadian governments both failed to properly do their jobs.

The cases that overturned approvals for Northern Gateway and Trans Mountain led companies to question investment in Canada. The end result is a Canadian oil patch in retreat.