CHICAGO (Reuters) - The city of Chicago asked a federal judge on Monday to bar President Donald Trump’s Justice Department from denying public-safety grants to so-called sanctuary cities that limit cooperation with a federal immigration crackdown.

A general view of the city of Chicago, March 23, 2014. REUTERS/Jim Young

The nation’s third-largest city sued U.S. Attorney General Jeff Sessions in August.

The lawsuit was filed after Sessions announced the Justice Department would bar cities from getting certain grants unless they allowed immigration authorities unlimited access to local jails and provided 48 hours’ notice before releasing anyone wanted for immigration violations.

Trump has made tougher immigration enforcement a centerpiece of his campaign and presidency, including vowing to build a wall on the U.S.-Mexican border. The federal government has also sought to crack down on sanctuary cities.

On Monday, Chicago attorney Ron Safer argued in U.S. District Court for a preliminary injunction that would apply nationwide while the court challenge proceeds.

Safer argued that Sessions lacked authority to attach conditions that would force Chicago to choose between funding for crime-fighting equipment and programs, and adopting an unconstitutional policy that would shatter trust with immigrant communities needed to solve crimes.

“This is a tremendously dangerous precedent to set,” Safer said, arguing that it could be applied to other grant programs to pressure cities to alter other local policies.

Acting Assistant Attorney General Chad Readler countered that the program was voluntary and tha funding amounted to less than 1 percent of Chicago’s public safety budget.

The government had the authority to attach such conditions, and cited the previous administration attaching requirements that the money not be spent on military-style weapons, he said.

“The courts have routinely recognized that the government can put conditions on spending to achieve things that they couldn’t otherwise directly achieve,” he said.

U.S. District Judge Harry Leinenweber did not say when he would rule but told both sides they would hear from him soon.

During oral arguments, Leinenweber said there were conflicting statistics on whether such policies help or hurt crime. He asked questions about the Justice Department’s authority to set such conditions as well as the city’s larger stance on illegal immigration.

“You don’t disagree that the United States should prevent illegal immigration, do you?” he asked. Safer acknowledged that the city did not support the practice of people coming to the United States without permission.

The Trump administration has requested $380 million in funding next year for grants for police equipment and programs to hundreds of cities. Chicago and nearby suburbs have applied for $2.2 million this year.