Media playback is unsupported on your device Media caption Just why has the US government partially shut down?

US President Donald Trump has renewed a threat to declare a national emergency to fund the construction of a wall on the Mexican border.

A row with Democrats over funding the wall has left the government partially shut down for 20 days, leaving some 800,000 federal employees unpaid.

On Saturday, the shutdown becomes the longest in US history.

Mr Trump says the wall, a key campaign pledge, is needed to tackle a security crisis of illegal immigration.

The Democrats say the wall is an "immorality" and a waste of taxpayers' money.

President Trump has refused to sign legislation to fund and reopen the government if it does not include $5.7bn (£4.5bn) for the wall.

What's behind Mr Trump's threat and what could happen?

He issued the threat on a visit on Thursday to a border patrol station in McAllen, in the Rio Grande Valley of Texas.

He said that if Congress did not approve funding for the wall, he would "probably... I would almost say definitely" declare a national emergency to bypass lawmakers.

Image copyright Reuters Image caption Mr Trump visited the US-Mexico border in Mission, Texas, on Thursday

"I have the absolute right to declare a national emergency," he said.

In a later interview with Fox News, he doubled down, declaring: "If we don't make a deal with Congress, most likely I will do that.

"I would actually say I would. I can't imagine any reason why not, because I'm allowed to do it."

"The law is 100 percent on my side," he said.

Mr Trump would have the right to undertake such a construction project in times of war and national emergency, usually allocating funds from the department of defence.

But bypassing Congress would be hugely controversial, sparking allegations of the overuse of executive powers and it would almost certainly face huge legal challenges.

Some US media reports suggest the White House is considering diverting some of the $13.9bn (£10.9bn) allocated last year by Congress for disaster relief in such areas as Puerto Rico, Texas and California to pay for the wall.

NBC News reported on Thursday that Mr Trump had been briefed on such a plan but the White House denied it.

Analysts say the national emergency move would provide political cover to reopen government while allowing Mr Trump to argue he has done all he can to fulfil his campaign promise.

The BBC's David Willis in Washington says that, with no further talks with the Democrats planned, this now seems the most likely option for the president.

Republican Senator Lindsey Graham, a key Trump ally, said there was no other pathway forward.

What did Mr Trump say at the border?

He was speaking at McAllen station, behind a display of weapons and cash said to have been seized by the border patrol.

He was joined by border patrol agents, and relatives of people killed by illegal immigrants.

Media playback is unsupported on your device Media caption Five questions about Trump's border wall

"If we don't have a barrier... you're not going to be able to solve this problem," he said, adding that people faced "hard work", "gruelling problems" and "a lot of death" without it.

Mr Trump added: "They say a wall is medieval... There are some things that work."

The president said in a national address on Tuesday the wall was needed to stem a "growing humanitarian and security crisis at our southern border", involving "thousands of illegal immigrants".

He pointed to illegal drug supplies, people trafficking and criminal acts by illegal immigrants in the US.

The Democrats say the wall is "ineffective" and "unnecessary" and an expensive bill to taxpayers that the president had said Mexico would foot.

Has Trump changed his pledge on funding the wall?

Speaking on Thursday, Mr Trump said he never meant that Mexico would make a one-time payment for the wall.

"When I said Mexico would pay for the wall in front of thousands and thousands of people... obviously I never meant Mexico would write a cheque," he said.

Image copyright AFP Image caption Mr Trump alongside a display of weapons, drugs and cash reportedly seized by US border patrol

However, this is contradicted by an archived campaign memo from 2016, where Mr Trump outlined how he planned to "compel Mexico to make a one-time payment" of $5-10bn (£4bn-£8bn) for the wall.

Mr Trump said on Thursday that, instead of a direct payment, Mexico would be "paying for the wall indirectly, many, many times over", under a new trade deal between the US, Mexico and Canada.

Economists have disputed this and critics say that any savings incurred due to the deal would go directly to private businesses rather than flow into US Treasury.

How is the shutdown progressing?

Partial shutdowns occur when Congress cannot agree a budget by a certain deadline or the president refuses to sign it.

This shutdown, which began on 22 December, has closed 25% of the government. Of the 800,000 federal employees affected, about 350,000 are furloughed - a kind of temporary lay off - and the rest are working without pay.

Media playback is unsupported on your device Media caption US shutdown: 'My son wants to sell art to pay our bills'

The first pay day since the shutdown falls on Friday and will pass without workers getting salaries. They include prison guards, airport security screening staff, and members of the FBI.

Some affected federal workers who spoke to the BBC said they had resorted to a number of measures, including taking other jobs, racking up credit card bills, tapping into savings or taking on loans at high interest rates to pay their bills.

Thousands have also applied for unemployment benefits.