Pedro Pereira Almao is performing industrial magic in his lab at the University of Calgary.

Lines from a row of tanks feed two greenhouse gases, carbon dioxide and methane, into a chamber the size and shape of a wasp's nest. Less than a minute later, the other end spits out carbon fiber, a more valuable material that is used in cars, planes, golf clubs and other useful things.

Pereira said the process, developed with a doctoral student, Mina Zarabian, could turn power plants, steel mills, or anything that burns fossil fuels into clean, green moneymakers. Using waste gases to produce cheap fiber could give rise to new uses, such as ultra-strong plywood.

Pereira and Zarabian are not the only ones imagining a different future for Alberta, the Canadian province of which Calgary is the largest city. In another building on campus, Ian Gates and his team are turning sticky bitumen from the tar sands into pellets that can be transported in unheated railcars.

"Bitumen balls," which look like licorice sweets, could be refined into oil, Gates acknowledged, but there could be a much bigger market for their use in other carbon-based products. Bitumen Beyond Combustion, a government-funded program, is exploring what Alberta could do with the 165 billion barrels of oil in the tar sands other than burning it. Promising contenders include using bitumen to make carbon fibers for high-tech composites, vanadium for batteries and steel, and high-grade asphalt for roads.

Alberta produces 81 percent of Canada's oil and gas. It exports most of it. But it is going through a rough patch.

Prices for Western Canadian Select, the benchmark for its heavy crude, began a steep slide in July, caused by overproduction, refinery maintenance work and a lack of pipeline capacity.

Nonetheless, Rachel Notley, who leads the province's left-leaning New Democratic Party (NDP) government, is doubling down on fossil fuel. She is demanding that the federal government speed up construction of a new pipeline to the West Coast. She wants a new refinery built, probably with government support. And she has said she will delay a promised cap on emissions from Alberta's tar sands. Notley dismisses as fantasy the idea that other industries could one day take the place of oil. "Back home we ride horses, not unicorns," she recently said.

This is bad news for Justin Trudeau, the Liberal prime minister, whose national climate-change strategy is in danger of coming apart. Canada's declared goal is to reduce emissions to 30 percent below 2005 levels by 2030. That means curbing Alberta's oil and gas production: the province leads the country in greenhouse-gas emissions, producing almost 263 megatons of the country's 704-megaton total in 2016, most of which comes from producing oil and gas.

Along with Saskatchewan, a much smaller energy producer, it is one of only two provinces with double-digit increases in emissions between 2005 and 2016, even as the national average declined by 3.8 percent.

In August, Notley withdrew her support for Trudeau's plan when the federal government did not immediately appeal against a court ruling halting construction of the Trans Mountain Expansion, a pipeline. It would have almost tripled the amount of Alberta crude carried to a terminal near Vancouver and onward to world markets. Ontario, Saskatchewan and Manitoba were already opposed to Trudeau's plan. He has the power to force it through. But Canada runs on federal-provincial consensus.

Alberta's intransigence may not be in its own interest. Global pressure to decarbonize is growing. The province faces competition from the United States, its biggest customer by far and now a net oil exporter. Eventually, Alberta will have to reduce its dependence on oil. That conversation is happening among academics, oil-and-gas workers and the broader public. But without political leadership the transition is likely to be rocky.

Notley has political reasons for keeping her public focus on oil. By law, she must call an election before the end of May. In opinion polls, her party is well behind the right-leaning United Conservative Party, led by Jason Kenney. It is easier for both politicians to blame the federal government than to admit that the oil industry and the province are suffering from self-inflicted wounds.

Alberta's fortunes rose when oil prices were high, but it did not save enough to cope when they fell. Money that poured into government coffers during a series of oil booms starting in 1947 poured out just as quickly. Alberta's sovereign-wealth fund, created in 1976, has been raided so frequently that it contains a paltry $13 billion. Norway's fund, set up 14 years later, has about $1 trillion, partly because its oil wells are more lucrative but also because its leaders have been much thriftier.

A second mistake was to rely for too long on just one customer, the United States, which buys almost all Alberta's oil and gas exports. This worked well for about six decades, until the shale revolution allowed the U.S. to pump vastly more.

Even the most starry-eyed scientists do not imagine that Alberta can revamp its economy overnight. Oil and gas account for a quarter of the province's GDP, and will continue to be the largest slice for decades. The next two most important sectors, construction and property, rise and fall with the oil industry.

But the reluctance even to face the need for change is worrying. "A lot of people think we've always been oil and gas and they don't think it's possible to pivot," said Terry Ross of the university's Schulich School of Engineering. For a province of horse-riders, that is a dangerous shortcoming.