Media playback is unsupported on your device Media caption Trump and the facts about the migrant caravan

A US federal judge has blocked an order issued by President Trump to deny the possibility of asylum to migrants crossing the southern border illegally.

US District Judge Jon Tigar in San Francisco issued the temporary restraining order after hearing arguments by civil rights groups.

Mr Trump signed the order earlier this month as thousands of migrants made their way towards the US border.

He cited national interest concerns but was opposed by civil rights groups.

Migrants from across Central America have been travelling north for weeks towards the US-Mexico border. Mr Trump has described the group as a "large caravan of people".

They say they are fleeing persecution, poverty and violence in their home countries of Honduras, Guatemala and El Salvador.

In the run-up to the US mid-term elections, President Trump said many of the migrants were criminals, called the caravan an invasion, and ordered troops to the border. He also repeatedly suggested it was politically motivated.

Image copyright Reuters Image caption About 3,000 members of the caravan have so far arrived in Tijuana

Department of Homeland Security spokeswoman Katie Waldman and Justice Department spokesman Steven Stafford called the asylum system "broken" in a joint statement, noting their departments will continue "to defend" the policy.

They said the current system is "being abused by tens of thousands of meritless claims every year", and supported Mr Trump's actions as "legitimate and well-reasoned".

"It is absurd that a set of advocacy groups can be found to have standing to sue to stop the entire federal government from acting so that illegal aliens can receive a government benefit to which they are not entitled."

What did the judge say?

Judge Tigar, in his ruling, said current legislation made it clear that any foreigner arriving in the US "whether or not at a designated port of arrival" could apply for asylum.

He said Mr Trump's proclamation on 9 November was an "extreme departure" from prior practice.

"Whatever the scope of the president's authority, he may not rewrite the immigration laws to impose a condition that Congress has expressly forbidden," Judge Tigar added.

He was responding in a case brought by the American Civil Liberties Union (ACLU), the Southern Poverty Law Center and the Center for Constitutional Rights.

They argued that Mr Trump's ruling was illegal.

The judge's restraining order comes into immediate effect and remains in place until a court hearing in December to decide on the case.

What is President Trump's order?

The proclamation on 9 November says that anyone who wants to claim asylum in the US has to come in through official points of entry - and their cases will not be heard if they enter illegally.

The ban was to last 90 days or until the US reached an agreement with Mexico to turn back asylum-seekers.

Under US law, there is a legal obligation to hear asylum claims from migrants if they say they fear violence in their home countries - regardless of how they have entered the country.

But the Trump administration invoked the same executive power he used to justify his travel ban on people from several Muslim-majority nations last year.

It said the president had the power to "suspend the entry of all aliens" and to impose "any restrictions he may deem to be appropriate on them" if they were judged to be "detrimental" to US interests under the Immigration and Nationality Act.

A statement at the time said: "We are using the authority granted to us by Congress to bar aliens who violate a presidential suspension of entry or other restriction from asylum eligibility."

There has been no response yet to the San Francisco ruling.

What is the situation on the US-Mexico border?

The US website Politico reports that 5,800 troops sent to bolster defences on the border will be home for Christmas. It quotes Army Lt Gen Jeffrey Buchanan as saying they have an "end date" of 15 December.

The decision to send troops came at the height of President Trump's dire warnings about the caravan during campaigning for the mid-term elections - and he was accused of deploying active troops for political purposes.

About 3,000 members of the caravan have so far arrived in Tijuana, the Mexican city bordering the US.

The city's authorities expect numbers to reach 10,000 in coming weeks.

The US temporarily closed the San Ysidro border point, its busiest crossing with Mexico, on Monday to install new movable wire-topped barriers.

How hard is it to win US asylum?

Claiming asylum is a long and difficult process, and people need to prove they are fleeing, or fear prosecution or torture in their country. Economic migrants do not qualify for asylum.

Most of them go through a process called "credible fear", in which an asylum officer examines their case. If the fear is determined to be credible, the individuals are referred to immigration courts. In negative cases, they are ordered to be removed.

Between October 2016 and September 2017, officials found 60,566 people to have credible fear among 79,710 cases, according to the US Citizenship and Immigration Services. Many of them remain detained during the process.

After that, it can take years until a decision is reached. In March, the USCIS had 318,624 pending cases.

Some 20,455 people were given asylum in 2016, according to the Department of Homeland Security.