Image copyright AFP Image caption Protesters gathered outside the US embassy in Mexico City

Former US President Barack Obama has attacked the Trump administration for scrapping his scheme to protect young undocumented migrants from deportation.

The Deferred Action for Childhood Arrivals (Daca) programme was rescinded on Tuesday, in a move that could affect some 800,000 beneficiaries.

While existing recipients will see no impact for at least six months, no new applications can now be made.

Appealing to Congress, Mr Obama said the decision was "cruel" and "wrong".

The so-called "Dreamers", mostly Latin Americans, were able to apply for work and study permits under the policy he introduced five years ago.

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

The Trump administration argues that the programme, which Mr Obama bypassed Congress in order to enact, was unconstitutional,

In a tweet, President Donald Trump, said he now looked forward to working with both Democrats and Republicans in Congress to "address immigration reform in a way that puts hardworking citizens of our country 1st".

"Congress now has 6 months to legalize DACA (something the Obama Administration was unable to do). If they can't, I will revisit this issue!" he added, in a second tweet.

Police in New York made at least a dozen arrests when protesters rallied in front of Trump Tower, US media report, but there were no reports of clashes.

Media playback is unsupported on your device Media caption Harvey hero now faces Daca deportation

Trump switches the pressure

By Anthony Zurcher, BBC News, Washington

Candidate Trump promised to do away with Daca, despite warnings from a cross-party collection of politicians. Or, knowing this president, objections from "the establishment" only make him more determined to act.

Fortunately for him, unlike repealing Obamacare or building his Mexican border wall, he does not need Congress's help here.

In fact, by setting a six-month fuse on the effects of Daca's termination - and stretching the impact out over the next two years as work permits expire - Mr Trump puts all the pressure on legislators.

It will not be easy for Daca supporters in Congress. They will have to get legislation passed over the objection of immigration hawks in the House. It may also need 60 votes in the Senate to break a filibuster, if the bill is packaged with hardline immigration measures. What is more, Congress already has its hands full with other pressing issues - hurricane relief, budget resolutions, the need to authorise new government debt and, at some point, tax reform.

If Congress fails to act, Republicans with tough re-election races will be in a difficult spot, facing angry constituents just as the campaign season gets into gear.

The president, however, satisfies his anti-immigration base with this move - and washes his hands of the matter. The loyalists who have stood by him are rewarded, others in his party be damned.

Read Anthony's full analysis

What did Obama say?

Mr Obama wrote on Facebook: "To target these young people is wrong - because they have done nothing wrong."

Image copyright AFP Image caption Protesters turned out in Los Angeles

"Ultimately, this is about basic decency," he said. "This is about whether we are a people who kick hopeful young strivers out of America, or whether we treat them the way we'd want our own kids to be treated."

Despite bypassing Congress himself over the issue, the former president said: "Now that the White House has shifted its responsibility for these young people to Congress, it's up to members of Congress to protect these young people and our future."

In a statement, House Democratic leader Nancy Pelosi also slammed Tuesday's decision and called on majority Republicans in Congress to join Democrats in immediately moving to safeguard Daca recipients.

Image copyright Reuters Image caption Senator Richard Durbin (left) and Senator Lindsey Graham spoke at the US Capitol

Two senators from the opposing parties held a joint news conference to call for bipartisan legislation to protect Dreamers.

"The clock is ticking," Democrat Dick Durbin said, while Republican Lindsey Graham said: "We believe in doing it right but 'right' means taking care of these kids."

The Mexican government said in a statement (in Spanish) that it profoundly regretted the scrapping of Daca and would step up its consular work on behalf of its citizens who are affected.

Why was the policy scrapped?

Mr Trump took a hard line on immigration while campaigning last year and promised to scrap Daca if elected.

In a statement, he said he did not "favour punishing children, most of whom are now adults, for the actions of their parents".

"But we must also recognise that we are nation of opportunity because we are a nation of laws," he added.

The scrapping of Daca was announced on Tuesday by Attorney General Jeff Sessions who described Mr Obama's policy as an "open-ended circumvention of immigration laws".

"There can be no path to principled immigration reform if the executive branch is able to rewrite or nullify federal laws at will," Mr Trump said.

Media playback is unsupported on your device Media caption 'We won't go back into the shadows', says this undocumented immigrant

What happens to current 'Dreamers'?

No new first-time requests will be acted on after 5 September, Department of Homeland Security (DHS) Acting Secretary Elaine Duke said in a memo released after Mr Sessions spoke.

However, no existing beneficiaries of the policy will feel any impact for six months, the period of time allotted for Congress to "deliver on appropriate legislative solutions".

People who have current Daca work authorisation will be able to keep it until it expires while people whose permits expire in less than six months can renew before 1 October for another full two years.

In order to qualify for Daca, applicants under the age of 30 had to submit personal information to the DHS.

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

They had to go through an FBI background check and have a clean criminal record, and either be in school, have 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.