The policy lacks sufficient protections to ensure migrants don't face "undue risk to their lives or freedom" in Mexico, the judge said. Seeborg also said a law that President Trump's administration cited as its authority to send back migrants does not apply to asylum seekers such as those who sued.
It was not immediately clear whether the administration would ask an appeals court to put the ruling on hold. The U.S. Department of Justice declined to comment.
The White House responded on Tuesday saying President Trump "will do whatever it takes" to protect Americans following Seeborg's decision.
Press secretary Sarah Sanders tweeted Tuesday that a "liberal activist judge in San Francisco ruled the United States and Mexico can't work together to address asylum issues at the border." She claims Mexico is now doing more to secure the U.S. border than Democrats in Congress and calls the situation "sad."
The launch of the policy in January at the nation's busiest border crossing — in San Diego — marked an unprecedented change to the U.S. asylum system, government officials and asylum experts said. Families seeking asylum typically have been released in the U.S. with notices to appear in court.
The Trump administration says the policy responds to a crisis at the southern border that has overwhelmed the ability of immigration officials to detain migrants. Growing numbers of families are fleeing poverty and gang violence in Guatemala, Honduras and El Salvador.
The ruling came a day after Homeland Security Secretary Kirstjen Nielsen resigned and as the administration faces repeated court setbacks on strict anti-immigration measures that were a signature campaign promise for Trump, including losses on such policies as separating families at the border and ending protections for young immigrants.
The lawsuit says the Trump administration is violating U.S. law by failing to adequately evaluate the dangers that migrants face in Mexico.
Under the new policy, asylum seekers are not guaranteed interpreters or lawyers and don't get to argue to a judge that they face the potential of persecution or torture if they are sent back to Mexico, Judy Rabinovitz, an attorney for the American Civil Liberties Union, said at a March court hearing.