European Union leaders have granted the UK a six-month extension to Brexit until 31 October, after five hours of talks in Brussels.

But how did this happen? BBC Brussels Reporter Adam Fleming explains all.