Fresh diplomatic efforts are under way to try to end Libya's bloody civil war, with the UN special envoy flying to Tripoli to hold talks after Britain followed France in accepting that Muammar Gaddafi cannot be bombed into exile.

The change of stance by the two most active countries in the international coalition is an acceptance of realities on the ground. Despite more than four months of sustained air strikes by Nato, the rebels have failed to secure any military advantage. Colonel Gaddafi has survived what observers perceive as attempts to eliminate him and, despite the defection of a number of senior commanders, there is no sign that he will be dethroned in a palace coup.

The regime controls around 20 per cent more territory than it did in the immediate aftermath of the uprising on 17 February.

The main obstacle to a ceasefire, so far, has been the insistence of the opposition and their Western backers that Colonel Gaddafi and his family must leave Libya. But earlier this month Mustafa Abdul Jalil, the leader of the Transitional National Council, stated that the dictator can remain in the country if he gives up the reins of power.

The French President, Nicolas Sarkozy, had wanted to declare victory in a Bastille Day speech on 14 July. Soon after this date, the country's Defence and Foreign Ministers pressed the case for a negotiated settlement.

The UK, which appeared to have been taken by surprise at the French volte-face, tried to maintain a tough line. But that has also changed in the last 48 hours, with first Downing Street and then the Foreign Secretary William Hague saying that Colonel Gaddafi may after all be allowed to remain in his homeland. Mr Hague said the UK would support whatever agreement was reached by the two sides in Libya.

Many senior British military officers have been less than enthusiastic about the Libyan mission, questioning its direction, and privately complaining that it is a distraction from unfinished business in Afghanistan. David Cameron's attempts to censure commanders who have raised concerns about fighting two wars while resources are being cut back has also led to growing dissatisfaction.

The UN envoy to Libya, Abdul Elah al-Khatib, had met opposition leaders in Benghazi before flying to Tripoli.

Meanwhile, the Libyan regime, which had offered an unconditional ceasefire a month ago, with senior members indicating that Colonel Gaddafi would be eased out, appears to have hardened its position, with officials maintaining that Nato bombing must stop before any talks can be held and demanding the release of Libyan assets frozen by the international community.

It remains unclear how a peace deal would be policed. Nato countries are adamant that they do not want to put boots on the ground, while Alain Le Roy, the UN's head of peacekeeping operations, has stated that the organisation only has limited manpower. The rebel administration is wary of involving African Union forces, holding that many of the governments of member states were clients of the Gaddafi regime.

* The Lockerbie bomber Abdelbaset al-Megrahi, who was released from prison in Scotland almost two years ago in the expectation that he would die within three months, has attended a pro-Gaddafi rally in Libya.