BP has secured a $900m (£455m) gas exploration deal with Libya, in a sign of Tripoli’s transformation from pariah to attractive investment destination for UK and US companies.

Tony Hayward, BP’s new chief executive, described the agreement as the group’s “single biggest exploration commitment”. The deal coincides with a visit to Tripoli by Tony Blair, the outgoing UK prime minister, who described the contract as “unthinkable” only a decade ago.

US and British energy companies have been scrambling to get back into Libya over the past two years to secure a share of the country’s largely unexplored gas and oil reserves.

Some analysts said BP was “a little behind the curve”, returning to Libya after oil groups including Royal Dutch Shell and ConocoPhillips had already made the move. But BP needs to expand in new areas, especially as it could lose one of its main Russian assets, the Kovykta gas field.

“As Russia becomes more of a risk, BP’s portfolio starts to look weaker compared with Shell’s,” said Oswald Clint, oil analyst at Sanford Bernstein. “Opportunities are few and far between, and BP needs to grasp all the opportunities it can.”