Media playback is unsupported on your device Media caption Nick Kwek toured the border dividing the US state of Arizona and Mexico's Sonora

US congressional talks over a border security deal have stalled, raising the chances of another government shutdown.

Negotiators were hoping for a deal by Monday to give Congress time to pass legislation by Friday, when the federal funding agreement runs out.

They remain divided on how many undocumented immigrants can be detained and funding for President Trump's promised border wall with Mexico.

The previous shutdown, lasting 35 days, was the longest in US history.

Hundreds of thousands of workers were furloughed while others in essential services, such as hospital care, air traffic control and law enforcement, worked without pay.

The cost to the US economy was estimated at $11bn (£8.5bn).

It was unclear how the negotiators would try to reach a deal, but a meeting has been scheduled for later on Monday, congressional aides said.

What is the latest impasse about?

The 17 Republican and Democratic negotiators from the Senate and the House have been holding talks to reach a border security agreement that can be accepted by Congress.

The latest impasse seems to be centred on a Democratic demand to limit the number of undocumented migrants already in the US who can be detained by Immigration and Customs Enforcement (ICE).

Democrats planned to cap the number of beds at detention centres reserved for those cases at 16,500.

By doing that, they hoped to force ICE to focus on detaining irregular migrants with criminal records instead of those who have overstayed their visas and, Democrats say, are productive and offer no threat.

Media playback is unsupported on your device Media caption Other presidents got money for a border barrier - why not Trump?

They were also looking at between $1.3bn and $2bn in funding for Mr Trump's proposed border wall, a long way off the $5.7bn the president has been demanding.

In a series of tweets on Monday, President Trump said that Democrats needed to "loosen up", adding that their latest demand relating to the detention of migrants was "crazy".

The president had earlier said the Democrats were "behaving, all of a sudden, irrationally".

Lead Republican negotiator Sen Richard Shelby told Fox News: "I'll say 50-50 we get a deal... The spectre of a shutdown is always out there."

However, one of the Democratic negotiators, Jon Tester, said there was still hope that a deal could be reached in time. Also speaking to Fox News, he said: "Negotiations seldom go smooth all the way through."

As wall discussions labour on, Mr Trump plans on sending over 3,700 active troops to the US-Mexico border to help agents with security efforts this month. With over 2,000 troops already at the border, the new deployment would top November's election-time numbers of 5,900.

Meanwhile, pushing back against the Trump administration's call for border states to help with security, California's Democratic Governor Gavin Newsom says he will recall hundreds of the state's national guard from the border.

Gov Newsom's move follows his Democratic colleague, Gov Michelle Grisham of New Mexico, who pulled her state's troops from the border last week.

Both governors have cited the withdrawal as a retaliation against Mr Trump's "fear-mongering".

Why is there a risk of another shutdown?

On 25 January, President Trump agreed to a three-week spending deal to end the shutdown and allow Congress to reach an agreement.

That funding ends at midnight on Friday. Another short-term deal could prevent a new shutdown, according to the New York Times.

Mr Trump - who has suggested the talks are a "waste of time" - made building a wall on the border with Mexico one of his key promises in the 2016 campaign.

The president has backed away from his calls to make Mexico pay for a concrete wall but during his State of the Union speech last Tuesday - delayed because of the previous shutdown - he insisted on a "smart, strategic, see-through steel barrier".

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

He has previously threatened to declare a national emergency and fund the wall without Congress. But this idea is disliked even by some fellow Republicans and Democrats are likely to challenge it in courts.

Mr Trump said on Saturday the wall would "get built one way or the other!" He is set to hold a rally in the border city of El Paso, in Texas, later on Monday to gather support for his wall.

Ahead of his visit, local officials denounced the president's remarks that a fence built there more than a decade ago reduced criminality.

What would happen in a shutdown?

Federal agencies including the departments of Homeland Security, State, Agriculture and Commerce could lose access to money and begin to close down again, affecting about 800,000 federal employees, who would go unpaid.

During a shutdown, essential services continue to operate, with workers being required to show up. Last time, some employees continued to work unpaid but many others called in sick.