Image caption Various NGOs have protested at the talks in Doha

There has been a historic shift in the UN climate talks in Qatar, with the prospect of rich nations having to compensate poor nations for losses due to climate change.

The US has fiercely opposed the measure - it says the cost could be unlimited.

But after angry tussles throughout the night the principle of Loss and Damage is now in the final negotiating text.

Small island states at risk from inundation say they will walk out if the US vetoes the proposed deal.

The political stakes are high. The EU's position is not yet well defined, but soundings suggest that it can live with the text.

The US will be seeking support from other big polluters - like Canada - likely to face liability for climate damages.

If the US is left alone fighting against the chair's text, its negotiators face a dilemma - either to bow to the majority and accept that the nations which caused climate change bear a moral responsibility to other nations damaged by it, or to refuse to sign.

If the US vetoes the text, President Barack Obama will be accused of hypocrisy and failure after re-committing himself to tackling climate change since his re-election.

"I will block this. I will shut this down Todd Stern, US chief negotiator

If he agrees the text he will face criticism from Republicans, whilst he tries to negotiate his own deal over US government finances.

One campaign group in Doha tweeted that before the text was agreed Todd Stern, the US chief negotiator, was heard saying: "I will block this. I will shut this down."

Saleem ul-Huq, from the think-tank IIED, told the BBC: "This is a watershed in the talks. There is no turning back from this. It will be better for the US to realise that the principle of compensation is inevitable - and negotiate a limit on Loss and Damage rather than leave the liability unlimited.

"[President Obama] has just asked Congress for $60bn (£37bn) for the effects of Sandy - developed nations are already having to foot the bill for loss and damage of their own."

The Qatari chair has warned delegates that only a few hours remain to sign off the deal. He says the conference will not overrun by another day.

Principle at stake

It is a point of principle that is at stake here for developing countries. In the end it's questionable how much extra money a Loss and Damage Mechanism might bring.

Already poor nations are bitter that rich nations, particularly the US are dragging their feet over a promise made at the failed Copenhagen climate summit to mobilise $100bn by 2020 to help poor nations get clean energy and adapt to climate change.

The developing countries say the original sum was too low - especially in the light of Mr Obama's request to Congress for Sandy damages of $60bn, and the UK's bid to raise £200bn for clean energy by 2020.