U.S. officials mustn't remove the wire or tamper with it, U.S. District Judge Alia Moses said as she entered a temporary restraining order.
The exception is in cases of medical emergencies that would "most likely" result in serious bodily injury or death to a person, provided no "live-saving apparatus" is available, Judge Moses, an appointee of former President George W. Bush, wrote in her ruling.
The U.S. Department of Homeland Security (DHS), which includes border agents, told news outlets it doesn't comment on pending litigation but would comply with the order.
"Generally speaking, Border Patrol agents have a responsibility under federal law to take those who have crossed onto U.S. soil without authorization into custody for processing," the agency said.
Texas Gov. Greg Abbott, a Republican, called the ruling "another win for Texas and our historic border mission."
The wire was put into place as the governor's effort, called Operation Lone Star, to strengthen border security.
"Biden created this crisis and has tried to block us at every turn. Attorney General Paxton and I are pushing back," Mr. Abbott wrote on X.
Texas Attorney General Ken Paxton, another Republican, sued the Biden administration earlier in October for tampering with the barriers.
The temporary order is in place until Nov. 13, unless the court extends it.
The government is prohibited from removing the wire, concealing it, offering it to another person, selling it, and tampering with it.
A hearing on the bid from Texas for a preliminary injunction is scheduled for Nov. 7.