The handshake between then UK prime minister Tony Blair and Muammer Gaddafi in the desert in 2007 was not just the moment the Libyan leader cemented ties with an old foe. It was also a stark symbol of the role “Big Oil” played in foreign policy.

BP sealed a significant exploration deal on the same trip, which capped its efforts to nudge the UK government to re-establish ties with the late North African dictator while opening access to huge hydrocarbon resources on Europe’s doorstep.

The struggle for fossil fuel resources has influenced geopolitics for decades, from generating conflict and shaping relations between the west and Middle East to today’s controversy over the Nordstream 2 pipeline from Russia to western Europe.

But now the relationship between western oil companies and their governments is undergoing a dramatic shift as governments commit to going green and fossil fuels fall out of favour — a move that gathered pace in April when US president Joe Biden convened an international climate summit to put pressure on countries to cut emissions.

“There has always been the notion that geopolitical power writ large was tied to oil access,” said Greg Priddy, a former energy analyst for the US government. “Even as late as the Obama administration in the US there was a sense that major producers overseas were strategically important. But all that is changing.”

The shift was hammered home last month when the International Energy Agency released a report arguing that if the world was to cut greenhouse gas emissions to net zero by 2050 — a prerequisite to meet the Paris climate accord goal of limiting global warming to 1.5C above pre-industrial levels — exploration for new oilfields must immediately stop.

Even before the report, oil companies had slashed investment in risky frontier exploration, fearing oil consumption could peak in the coming decade.

But in countries where oil executives might once have played almost as big a role as ambassadors in managing relationships with foreign leaders, their influence is diminishing. Critics once complained of a “revolving door” between governments and oil groups, with officials taking posts in the industry after leaving public life. But governments no longer want to be seen backing fossil fuel companies overseas while pushing a domestic agenda based on renewables, say analysts.

In the US — the world’s biggest oil producer and consumer — the Biden administration has rejoined the Paris agreement, scrapped the Keystone XL oil pipeline and proposed unprecedented investment in clean energy. Internationally, the White House has pressed other countries to stop financing coal projects overseas — last month G7 nations pledged to do so by the end of this year — as well as leading the climate summit.

“With the change in administration in Washington, I think we have probably seen the twilight of the US government’s love affair with oil companies,” said Helima Croft, a former CIA analyst who runs commodity research at RBC Capital Markets.

“Safeguarding access to resources used to be seen as an important issue in Washington, but it is less so now with the focus on the energy transition and climate change.”

However attempting a global transition to renewables is a complex calculation, observers warn.

Big oil companies say that while they enjoyed support, they were never reliant on their governments to help them secure access to resources, and they remain welcome in many countries.

But industry figures argue politicians risk losing global clout by weakening their links with domestic oil and gas companies and steering developing countries away from fossil fuels. The US, for example, should use its own vast hydrocarbon resources to support potential allies that might otherwise rely on supplies from countries such as Russia, they say.

“There’s a geopolitical competition with China on right now for economic influence over many parts of the world,” said a former senior US national security adviser who now works for a large US oil company and asked to remain anonymous. “The US has advantages with its LNG supplies but seems less keen to use them.”

Jason Bordoff, a former special assistant to Barack Obama and director of the Center on Global Energy Policy at Columbia University, noted there was still little let-up in global demand for oil.

“The IEA road map was pretty striking in highlighting what needs to change, but also striking in saying nothing is changing yet — oil demand is still going up,” Bordoff said.

The role of natural resources in foreign policy would evolve with the energy transition, he said. Critical minerals for batteries or access to alternative fuels such as hydrogen meant relationships between big producers of raw materials and governments would change rather than vanish.

“Even if all of the problems of energy geopolitics were resolved by decarbonising, the energy transition is undoubtedly going to create new ones,” he said.

In the end high level political backing cannot protect oil companies from events. Blair may have paved the way for BP but its investment in Libya has not borne fruit, with the 2011 civil war and subsequent strife disrupting its plans. In 2018 the company sold half its stake in the exploration rights to Italy’s Eni.

“There always was an interesting relationship between government and large oil companies but I’ve never been quite sure what way the influence went,” said Professor Paul Stevens, distinguished fellow at Chatham House.

“But with oil on the way out . . . the companies are fighting a rearguard action and there’s not a lot the government can do for them.”