Media playback is unsupported on your device Media caption John Kerry held his granddaughter as he signed the book during the signature ceremony for the Paris Agreement

Amid hope and hype, delegates have finished signing the Paris climate agreement at UN headquarters in New York.

Some 171 countries inked the deal today, a record number for a new international treaty.

About 15 nations, mainly small island states, had already ratified the agreement.

But dozens of other countries were required to take this second step before the pact came into force.

UN Secretary-General Ban Ki-moon said: "Paris will shape the lives of all future generations in a profound way - it is their future that is at stake."

Speaking at the opening ceremony, he said the planet was experiencing record temperatures: "We are in a race against time. I urge all countries to join the agreement at the national level.

"Today we are signing a new covenant for the future."

Image copyright Getty Images Image caption UN Secretary-General Ban Ki-moon said delegates were signing "a new covenant for the future"

As the world marked the 46th Earth Day, UN climate chief Christiana Figueres explained what now needed to happened.

"Most countries, though not all, need to take the signed document and go back home and go to ratification procedures that in most countries requires parliamentary discussion and decision."

Analysis

David Shukman, Science Editor, New York

Only a few years ago the very idea of a global treaty to limit climate change seemed almost impossible. The ghosts of the failed Copenhagen summit in 2009 haunted the negotiations.

Now, in a total transformation in morale, almost all of the world's governments are here in New York to support the new Paris Agreement. The sheer scale of the turnout is seen as a signal of political determination. The atmosphere is positive, up to a point. Tough challenges lie ahead.

Image copyright Getty Images Image caption Hollywood actor and campaigner Leonardo DiCaprio also spoke at the ceremony

One is the task of ratification, another the continuing arguments over cash, a third the basic fact that the deal was only made possible because each country's actions are entirely voluntary. And then there's the awkward truth that, amid the celebrations, all eyes are transfixed by events beyond the UN buildings.

Mention of the name Trump triggers nervous laughter. A Republican victory would presumably lead to America's withdrawal from the agreement. And that would risk undermining the entire process.

Hollywood actor and climate change campaigner Leonardo DiCaprio said: "After 21 years of debates and conferences it's time to declare no more talks, no more 10-year studies, no more allowing the fossil fuel companies to manipulate and dictate the science and the policies that affect our future. This is the body that can do what is needed."

France's president Francois Hollande said the agreement in Paris was an "emotional moment, rare in the lives of politicians and leaders".

He added: "We need to go further than the pledges made there."

Even though the US and China represent around 38% of global emissions, getting to the 55% figure will not be that easy.

The European Union, which represents just under 10% of global CO2, will take a considerable amount of time as each of the 28 members has to ratify it themselves.

That is unlikely to begin until the EU can agree how much of the carbon cutting each country will have to undertake.

Small island states were upset with this approach.

Media playback is unsupported on your device Media caption A sound guide to temperature rises

"That exercise is going to take too long, we should all join together and tell our friends in the EU they must move along more quickly than that," said the Marshall Islands Ambassador for climate change, Tony De Brum.

"We did not expect that kind of distance in the process of ratification and approval."

Indigenous rights campaigner Hindou Oumarou Ibrahim commented: "Climate change is adding poverty to poverty every day, forcing many to leave home for a better future.

"If you do not increase finance for adaptation soon, there will be no one to adapt."

President Obama is also keen to see the new agreement take effect before he leaves office next January. A little known clause in the treaty means it would take four years if a new leader, less committed to climate action, wanted to take the US out of the agreement.

Other countries are also aware of this and are watching the US election process very closely.

"We don't know who the next President will be and what stand the new administration will take," India's environment minister Prakash Javadekar told BBC News.

"What happens in the US will have a definite bearing on how the world takes all these ideas and commitments and pledges in effect. So people are eagerly awaiting what happens in the US."

China said it would "finalise domestic procedures" to ratify the Paris Agreement before the G20 summit in China in September.

There is obvious delight here in New York at the record turnout of countries and leaders to sign the agreement. But some attendees are cautioning that this is merely the first rung on a very difficult ladder.

If action to cut emissions isn't ramped up quickly, and the world warms by significantly more than 2C, there would be consequences.

"If you have seen Syrian refugees, get ready to see climate refugees - it will be worse," said Tosi Mpan-Mpanu from the DRC, the chairman of the Least Developed Countries group in the UN talks.

"If people have had decades of gaining assets and livelihoods which are completely depleted in a season's dry weather - what do they have left?

"It is an open door to Boko Haram, it is an open door to Daesh, because people will be just desperate," he told BBC News.

Follow Matt on Twitter and on Facebook.