Image copyright AFP/Getty Image caption Daca supporters have protested against the decision to scrap the programme

President Donald Trump has criticised the US courts after a judge blocked him from ending protection for migrants who entered the US illegally as children.

Mr Trump said the court system was "broken and unfair".

In September, he rescinded Deferred Action for Childhood Arrivals (Daca), but San Francisco Judge William Alsup said it had to stay while litigation against Mr Trump's move continued.

The Obama-era scheme protects some 800,000 people.

It also provides temporary permits for work and study.

Mr Trump attacked the ruling on Twitter: "The opposing side in a case (such as Daca) always runs to the 9th Circuit and almost always wins before being reversed by higher courts."

Judge Alsup's court is the District Court for the Northern District of California. The Ninth US Circuit Court of Appeals commonly examines appeals of rulings made in Judge Alsup's court and others.

Media playback is unsupported on your device Media caption Daca recipients: 'Life in the US is like a rollercoaster'

Earlier, White House press spokeswoman Sarah Sanders described the ruling as "outrageous".

What did the San Francisco judge order?

In his ruling, Judge Alsup stated that "the government is hereby ordered and enjoined, pending final judgment herein or other order, to maintain the Daca programme on a nationwide basis on the same terms and conditions as were in effect before the rescission".

He said the justice department's argument that the scheme was illegal was based on a "flawed legal premise".

The district judge ordered the government to process renewal applications from people who had previously been covered.

However, this would not be the case for those who had never before received protection under the programme.

Media playback is unsupported on your device Media caption The US president earlier said he had "great love" for Daca Dreamers

When did Mr Trump want to end Daca?

Despite scrapping the programme in September, President Trump delayed enforcement to give Congress until March to enact a replacement plan for Daca recipients, who are known as "Dreamers".

"We want to see something happen with Daca," Mr Trump said in a cabinet meeting on Wednesday, "It's been spoken of for years. Children are now adults in many cases."

On Tuesday, Democrats and Republicans announced that they would work together on a new immigration bill to protect border security, chain migration, the visa lottery system and the Daca.

Democrats have repeatedly said that they will block any legislation that contains funding for the border wall with Mexico - a key campaign pledge of Mr Trump's.

What is Daca?

In order to qualify for the 2012 scheme, applicants under the age of 30 were required to submit personal information to the Department of Homeland Security, including addresses and phone numbers.

They had to pass an FBI background check, have a clean criminal background, and either be in school, recently graduated or have been honourably discharged from the military.

In exchange, the US government agreed to "defer" any action on their immigration status for a period of two years.

The majority of dreamers are from Mexico and other Latin American countries.

The justice department has said no current Daca recipients will be affected by the decision to scrap the scheme before 5 March 2018, but no new applications will be taken.

Media playback is unsupported on your device Media caption Where do America's undocumented immigrants live?

Are illegal border crossings on the rise?

Mr Trump's bipartisan meeting on Tuesday came the same day the US Department of Homeland Security released data showing

Border arrest figures are used as an indicator for the level of overall illegal crossings.

The biggest monthly drop came in the months after Mr Trump won his party's presidential nomination, and continued into the first few months of his presidency - from October 2016 to April 2017.

But since April 2017, when nearly 16,000 people were arrested on the US southern border, the number of illegal immigrants has started to climb. DHS recorded more than 40,000 illegal entries last month, according to the latest data.

"The significant increase over the last month in the number of family units and unaccompanied children coming across the border illegally highlights the dire need for Congress to immediately adopt responsible pro-American immigration reforms," said DHS spokesman Tyler Houlton.

The New York Times reports that migrant shelters - which help provide assist to people who have just illegally crossed - are filling up as the number of crossings again rose to 2014 levels under former President Barack Obama.