The UK Government has confirmed it will foot the policing bill should Donald Trump visit Scotland later this month.

Justice Secretary Humza Yousaf wrote to Home Secretary Sajid Javid after it emerged a US presidential visit could cost Police Scotland around £5 million and require more than 5,000 officers.

Responding to the letter, Chief Secretary to the Treasury Liz Truss said: "The final details of the President's visit to the UK, including Scotland, are still to be confirmed.

"As you are aware, policing is a devolved matter in Scotland.

"However, on an exceptional basis, I can confirm that the Treasury would provide ring-fenced funding of up to £5 million to cover the costs incurred by Police Scotland should a visit by the President be confirmed."

READ MORE: Humza Yousaf demands Home Office foots £5m policing bill for expected Donald Trump visit to Scotland

Mr Yousaf said: "This is a welcome decision, given that President Trump is coming to the UK on the invitation of the UK Government.

"However, we should not have had to force this decision - and there should never have been an assumption that the Scottish Government would pick up the tab.

"Although a visit to Scotland has not yet been confirmed, we continue to plan for every eventuality with our key partners including Police Scotland."

First Minister Nicola Sturgeon hailed the announcement as a "big result" for Mr Yousaf, who was "standing up for Scotland's police".

READ MORE: First power generated by Trump row offshore wind farm

Police Scotland interim Chief Constable Iain Livingstone also welcomed the announcement.

Writing on Twitter, he said: "Welcome confirmation that all costs incurred by Police Scotland as consequence of any visit by President Trump going to be covered by Treasury. Detailed planning continues, another busy and demanding summer. Fair outcome."

Last week, Mr Livingstone told the Scottish Police Authority board contingency planning was under way for a visit, with rest days cancelled and shifts changed for many police officers.

He said that even without an appearance from Mr Trump north of the border, planned demonstrations and protests across the country will have significant implications for policing resources.

Concerns had been raised over how the costs would be met given the force's £35 million budget deficit.

READ MORE: Donald Trump branded 'serial child-abuser' as Scots MPs condemn his UK visit

Mr Trump is due to make his first presidential trip to the UK after attending the Nato summit in Brussels on July 11 and 12.

The White House and Downing Street have confirmed he will hold talks with Theresa May on Friday July 13, but other details are still being worked out.

There has been speculation the president, who owns two golf resorts in Scotland, could extend his stay in order to play on one of his courses.

Meanwhile, anti-Trump protests have been arranged in Edinburgh and Glasgow to coincide with the visit.

Mr Livingstone said the president could be in Scotland between July 12 and 15.