Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

SAN FRANCISCO — A judge in San Francisco has blocked the Trump administration from ending protections that allowed immigrants from four countries to live and work legally in the United States.

U.S. District Judge Edward Chen in San Francisco on Wednesday granted a request for a preliminary injunction against the administration's decision.

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

The ruling comes in a lawsuit challenging the administration's decision to end temporary protected status for people from Sudan, Nicaragua, Haiti and El Salvador. The status is granted to countries ravaged by natural disasters or war. It lets citizens of those countries remain in the U.S. until the situation improves back home.

The lawsuit alleges the administration's decision was motivated by racism and cites Trump's vulgar reference to African countries during a meeting about immigration at the White House in January.

"This shows that Trump’s move to terminate TPS was based on his racial motivations and not in any law or consideration of safety," Working Families United, which supports temporary protected status, said in a statement. "With the suit still in court, Congress must act to create a pathway to legal residency and make the protections permanent."

U.S. Department of Justice spokesman Devin O’Malley said in a statement the Trump administration disagrees with the ruling.

"The Court's decision usurps the role of the executive branch in our constitutional order," he said. "The Court contends that the duly elected President of the United States cannot be involved in matters deciding the safety and security of our nation's citizens or in the enforcement of our immigration laws."

He vowed that the administration "will continue to fight for the integrity of our immigration laws and our national security."