Media playback is unsupported on your device Media caption Green campaigners have been protesting at the summit

Talks have continued well past the official close of business on the final day of a key UN climate summit in Peru aimed at advancing a new global treaty.

The negotiators in the capital, Lima, are tasked with preparing a text to serve as the basis for a new compact to be signed in Paris next year.

Long-running divisions between rich and poor countries are hampering progress.

US Secretary of State John Kerry has warned that the world is "still on a course leading to tragedy".

He said a deal was "not an option - an urgent necessity".

Negotiators have been meeting in Lima for almost two weeks to prepare the elements of the new treaty.

'Red lines'

A new text has been produced by the chairman of the talks in an effort to get a decision.

But environmental groups say that it is far too weak and threatens to leave many issues unresolved.

Lima climate talks

Image copyright AFP Image caption The negotiations are being hosted by Lima, the Peruvian capital

Conference runs from 1 to 12 December, attended by 195 countries

Negotiations aim to advance the outline text of an agreement on climate change, to be finalised in Paris by the end of 2015

Progress on approving the text has been slow

Countries are divided over whether developing countries should take on obligations to cut emissions

The talks come amid some of the hottest global average temperatures ever on record.

In his speech, Mr Kerry said no country should have a "free pass".

"I know this is difficult for developing nations. We have to remember that today more than half of emissions are coming from developing nations, so it is imperative that they act too."

But this approach is being resisted by a number of countries, including China and many others, who want to adhere to the idea of "common but differentiated responsibilities".

Some countries are suspicious that the text being developed here in Lima is an attempt to get round the concept of differentiation, which is embedded in the 1992 UN framework convention on climate change.

The issue has become critical as the chairs of the talks introduced a new draft text that many felt watered down the original commitment.

A large group of developing nations known as the G77 objected.

"This whole exercise is not meant to rewrite the convention, this is a firm basic position of the G77," said Antonio Marcondes, Brazil's representative at the talks.

Image copyright AP Image caption Drought in Sao Paulo, Brazil. The talks have highlighted divisions between developed and developing nations

"We stand behind the differentiation, we stand behind 'common but differentiated responsibilities', these are issues we hold very strong and these are definite red lines."

Another key battle was over the initial commitments that countries are expected to make by the end of March next year.

Rich and poor are still divided over what should be part of this package, known in the jargon of the UN talks as the "intended nationally determined contributions" (INDCs).

Developed countries want to restrict them to carbon cuts. Developing ones want them to include finance for adaptation.

Long night ahead

A further argument is over the idea that there must be some sort of review process before a new deal is signed.

It would essentially be an effort to ratchet up ambition by comparing and contrasting what countries had promised in the run up to Paris.

The idea, called an "ex-ante review", is seen as very important by some, especially the European Union.

But developing countries including India are dead set against it.

Image copyright Reuters Image caption More than 190 countries are represented at the talks

They say it is an issue of sovereignty. Outside parties, they argue, should not have the power to review what countries commit to by themselves.

"We favour a transparent presentation of country issues, but we think that an ex-ante review next year would be an unnecessary effort," said Mr Marcondes.

"It would detract from the main goal of reaching Paris with a new agreement."

These divisions are all variants of long-running splits between richer and poorer nations that have existed in the UN talks for 20 years.

The climate debate has often been neutered by the depth of these differences. It had been hoped that the positive signals from the US, China and the European Union before the meeting would help bridge the gaps, but trust is still short on the ground.

The president of the meeting, Manuel Pulgar-Vidal from Peru, earlier told delegates that they would not "leave Lima with empty hands".

"We can deal with this problem and we can send a strong signal," he said. "Don't leave me alone, we can work together. It won't be me that thanks you, it will be the world."

Follow Matt on Twitter: @mattmcgrathbbc