U.S. District Judge William Orrick issued the temporary ruling Tuesday in a lawsuit over the executive order targeting so-called sanctuary cities. The decision will stay in place while the lawsuit moves through court.
The Republican president's administration and two California governments that sued over the order disagreed about its scope.
San Francisco and Santa Clara County argued that it threatened billions of dollars in federal funding.
But an attorney for the Justice Department, Chad Readler, said at a recent court hearing that it applied to a limited set of grants.
Readler said less than $1 million was at stake nationally and possibly no San Francisco funding.