Image copyright Kiara Worth/IISD Image caption The Chilean presidency came in for severe criticism from many

At the conclusion of UN climate talks in Madrid, our environment correspondent Matt McGrath considers the key lessons.

1. Leadership is REALLY important

COP25 in Madrid only happened because the Chilean government, faced with mounting civil disorder, decided to cancel the meeting in Santiago.

Spain stepped in and in three weeks organised a well-resourced and well-run event.

However, the fact that it was being run by one government, while hosted by another, gave rise to severe difficulties.

Delegates were highly critical of the fact that when it came to the key text about ambition, the Chileans presented the lowest common denominator language first, resulting in a huge number of objections from countries eager to see more ambition on carbon cuts.

Experienced COP watchers said they should have started with high ambition and negotiated down to a compromise.

Insiders say that agreement was only found because of the influence of Spanish minister Teresa Ribera who played a key role in bringing parties together during the long, last night of negotiations.

2. Disconnect is the key word

This was the word that was most widely used to describe COP25.

There was a yawning gap between the demands of those outside the process and the actions of those within.

Image copyright Kiara Worth/IISD Image caption Campaigners staged their own final plenary session as they felt things were going awry in the real one

This disconnect was the difference between the urgency underlined by the latest science, the demands for more ambitious climate targets from school strikers around the world, and the torturous, convoluted nature of the talks.

During the talks, young activists staged an unauthorised protest that saw hundreds ejected by security.

"It's clear that civil society is at a boiling point, they are frustrated with the glacial pace and they are livid with the presence of polluters and their trade associations," said Sriram Madhusoodanan from Corporate Accountability, a campaign group that monitors the presence of the oil and gas industry at COP.

"If these talks are ever going to deliver, governments have to take a long serious look at why its failed for 25 years, and start by kicking polluters out."

3. Leipzig in September

This will be the most critical climate encounter in 2020.

The next conference of the parties may be in Glasgow, but the chance of any real success there will be determined, to a large extent by what happens in the EU-China summit taking place in the German city of Leipzig next September.

Image copyright Kiara Worth/IISD Image caption Tired negotiators worked through two nights as COP25 went into overtime

The hope is that by then the EU will have formalised its zero-carbon long term goal and also updated its 2030 pledge to cut emissions by 55% of 1990 levels.

The EU will likely try and secure agreement from the Chinese to improve their nationally determined contribution (NDC).

Back in 2014 the climate pact signed by President Obama and President Xi Jinping became the lynchpin of the Paris Agreement.

The BBC Briefing is a series of downloadable online guides to the big topics in the news. Click here if you want more context and facts about UK energy policy and the road to our net zero goals.

Download the updated BBC Energy Briefing (10.4MB) (PDF, 10.4MB)

Many observers hope that if the EU and China can do the same, it will be a massive boost for Glasgow.

"The good news is that the Chinese president is coming to the summit," said Li Shuo, a senior policy adviser with Greenpeace China.

"From the Chinese perspective the NDC enhancement decision is one that has to be made at the very top level so the fact the president is going would provide one potential condition for a political level decision."

4. The elephant in the room….

At Paris in 2015, countries submitted their first climate plans, which was relatively easy for many of the larger developing countries.

But in 2020, they are supposed to do much more and as Madrid proved, many are fighting this hard.

Image copyright Kiara Worth/IISD Image caption Negotiators from small island states said they were excluded from some key meetings

The actions of the US in pulling out of Paris and adopting an antagonistic attitude to the COP have chimed with the desire among some of the larger emitters to put off difficult decisions.

That was clearly evident in Madrid.

So Australia fought hard to keep old carbon credits in the system because it wants to use them to reduce its own carbon rather than taking actions that might impact consumers.

India became much more vocal about the need for an examination of whether richer countries have done enough in the years running up to 2020.

If countries can't be persuaded to move away from these self-protective positions, Glasgow will suffer the same fate as the ill-fated Copenhagen COP in 2009.

5. Glasgow has a mountain to climb

The key takeaway from Madrid is that making progress in climate talks requires huge preparation, strong diplomacy and very committed leadership.

Image copyright Kiara Worth/IISD Image caption Some visitors were distinctly unimpressed by COP25

Because Madrid failed to clarify so many key issues the onus now falls on the UK to resolve many of the most challenging questions.

In Glasgow, the question of loss and damage, of carbon markets, transparency and many other technical issues will need to solved.

Most importantly the countries will have to agree a major boost in their carbon cutting if the world is to keep the rise in global temperatures under 1.5C this century.

At a time when the UK will be negotiating trade deals with the EU and with the US, it is going to require enormous diplomatic clout to deal with the climate question as well.

"The diplomacy to build the confidence of the Chinas and the Indias that they can do more and they will be supported, through economic co-operation and that everyone else is moving in that direction, is incredibly important for changing the politics heading into next year," said Jennifer Tollman, a climate expert with the E3G think tank.

"The UK can't do it on its own. They will have to outsource this to people they know and trust."