Media playback is unsupported on your device Media caption Thousands of protesters march through London

The police operation for Donald Trump's controversial visit to the UK in July cost nearly £18m, it is estimated.

Nearly 10,000 officers from across the country were needed to cover the US president's four-day trip, a National Police Chiefs' Council blog says.

It also says changes to pension rules could leave English and Welsh forces needing an extra £417m by 2020/21.

That is equivalent to nearly 10,000 officers, it said, expressing "grave concern" about force sustainability.

President Trump's visit coincided with increased demands on policing linked to the hot weather, summer festivals and the World Cup finals.

The policing bill, estimated after gathering data from forces across the UK, was revealed in a post by council chairwoman Sara Thornton.

"The majority of forces had to cancel officers' rest days, and extend the length of their shifts," she said.

She praised the "hard work" of officers in ensuring that the "public were kept safe throughout".

Image copyright Reuters Image caption Mr Trump met the Queen at Windsor Castle during his visit

During his UK trip President Trump visited Prime Minister Theresa May at her country residence Chequers.

He attended a dinner at Winston Churchill's ancestral home, Blenheim Palace, in Oxfordshire, met the Queen at Windsor Castle and played golf in South Ayrshire.

Although his schedule largely avoided big cities, protests about his presence in the UK were held in England and Scotland.

In London tens of thousands of people gathered at an anti-Trump march, which featured a crowd-funded balloon of Donald Trump as a baby, holding a mobile phone.

Image copyright Getty Images Image caption Mr Trump was booed by onlookers as he played golf in Turnberry, Scotland

The police operation did not go without incident. The US president and property magnate was heckled by protesters as he played at his golf course in Turnberry.

A paraglider flew close to the course's hotel with a Greenpeace banner reading: "Trump: well below par #resist".

Police Scotland said the man flying the glider had put himself "in grave danger" by breaching an air exclusion zone around the course.

In July the Treasury said it would fund policing costs of up to £5m for police operations during Mr Trump's visit to his Scottish golf course.

Before Mr Trump's visit to the UK the Police Federation said it would put "unquestionable pressure" on UK police forces.

Essex Police Assistant Chief Constable Pippa Mills apologised for the conditions that extra officers were expected to sleep in after pictures posted on social media showed rows of camp beds in a gymnasium. Alternative accommodation was found.

In her blog post, Chief Constable Thornton said financial issues dominated a meeting of the Chief Constables' Council this week.

A recent Treasury announcement flagging up a likely increase to employee pension contributions meant forces in England and Wales might need to find an extra £417m by 2020/21, she said.

"This is equivalent to nearly 10,000 officers and grave concern was expressed about further reducing the sustainability of local police forces," she said.

"There was general concern about the strain that forces are currently under and the impact on core policing such as answering emergency calls, investigating crime and neighbourhood policing."

The pensions matter had been raised with the government, while force chiefs were working with police and crime commissioners to build a case for increased resources in the next spending review, she added.