Major oil companies, under pressure from investors and environmentalists, are fleeing Canada’s oil sands, the fourth-largest oil reserve in the world and by some measures one of the most environmentally unfriendly. Investment in existing projects has stalled, and banks are refusing to fund new ones.

Nevertheless, oil production there is expected to continue for at least two more decades. Local companies have stepped in to keep working the existing mines and wells. Last year, the oil sands were on track to deliver more oil than ever.

Governments and financial institutions are pushing to wean the world from fossil fuels to address climate change. But demand for energy remains robust. So long as existing oil fields—no matter their carbon footprint—remain profitable, they are likely to remain in production long after big-name multinational companies walk away.

There are still roughly 170 billion barrels of thick, tar-like bitumen under boreal forests in the Canadian province of Alberta, the largest amount outside of Saudi Arabia, Venezuela and Iran. Domestic companies such as Canadian Natural Resources Ltd. CNQ 1.82% Suncor Energy Inc., SU -1.10% Cenovus Energy Inc. CVE -0.62% and Imperial Oil Ltd IMO 0.96% , an affiliate of Exxon Mobil Corp. XOM -0.72% , extracted more crude from those fields in last year’s third quarter than the same period a year earlier.

Politicians and others pushing for a rapid transition to cleaner energy sources face a conundrum. Despite intensifying efforts to transition the global economy away from fossil fuels, alternative energy sources currently come nowhere near meeting present demand. That means companies will continue to pump oil even from carbon-intensive sources.

“We will continue to see growth,” said Alex Pourbaix, chief executive of Calgary-based Cenovus, which doubled its dividend last year. Cenovus increased third-quarter oil sands production by almost 50,000 barrels a day.

Mr. Pourbaix said the world-wide push for renewable energy wouldn’t reduce oil’s importance as a cheap energy source anytime soon. “There’s no technology at all of scale that can replace what oil can do,” he said. “That’s just reality.”

The benchmark West Texas Intermediate oil price in the U.S., which fell to record lows in the spring of 2020, rose above $70 a barrel in June for the first time since 2018.

The sharp rise in prices has prompted even world leaders committed to reducing emissions to call for more production. President Biden asked the Organization of the Petroleum Exporting Countries last year to boost production, after gasoline prices climbed, and in November he released oil from the U.S.’s strategic reserve in a bid to tame gas costs. He also supported the construction of a replacement for Line 3, a pipeline operated by Calgary-based Enbridge Inc. that brings crude from the oil sands to the U.S.

Canadian Prime Minister Justin Trudeau is spending more than $12.5 billion to expand the Trans Mountain pipeline, which carries crude from the oil sands to Canada’s west coast. The expansion, when it is finished sometime in 2023, will triple Trans Mountain’s capacity to almost 900,000 barrels a day, giving companies such as Cenovus and Suncor greater access to growing markets in Asia.

Mr. Trudeau has said that money from Canada’s oil industry will fund its transition to greener energy.

The production increases in Canada’s oil sands are happening despite a yearslong flight of capital from the area. The region, once one of the energy world’s hottest investment destinations, has become a dead zone for foreign investment.