The 5th U.S. Circuit Court of Appeals ruled that Farmers Branch overstepped its authority in 2008 when it passed a law calling on the city's building inspector to check the immigration status of anyone wanting to rent an apartment who wasn't a U.S. citizen.

Under the law, undocumented immigrants would have been barred from rental housing, and landlords who knowingly allowed them to stay could have their rental licenses barred.

The appellate court said the city was seeking to exclude undocumented immigrants, particularly Latinos, under the guise of policing housing.

"Because the sole purpose and effect of this ordinance is to target the presence of illegal aliens within the City of Farmers Branch and to cause their removal, it contravenes the federal government's exclusive authority over the regulation of immigration and the conditions of residence in this country," the court's opinion stated.

The city had appealed the decision of U.S. District Judge Jane J. Boyle, who ruled two years ago that the law is unconstitutional after a lawsuit was filed by apartment owners and tenants.

William Brewer, the lead attorney for the plaintiffs, said he sensed a "strong undercurrent" throughout the appellate court's decision that Farmers Branch was engaged in discrimination. The ruling is particularly meaningful because the 5th Circuit has a reputation for conservatism, he said.

Brewer noted that the ruling affirms Boyle's decision that Farmers Branch must pay the plaintiffs' attorney fees, which before the appeal were nearly $2 million. He called that portion of the decision "a strong deterrent" against other cities seeking to pass similar laws.

"Clearly, both the trial court and the appellate court recognize that this ordinance was discriminatory," Brewer said.

Farmers Branch Mayor Bill Glancy said he will talk with City Council members before deciding whether to push for the matter to be heard by the full appeals court or the U.S. Supreme Court.

Glancy, who took office last year, said he supported the law and other efforts to keep undocumented immigrants out of Farmers Branch, a suburb with nearly 29,000 residents northwest of Dallas.

"Basically, it has discouraged people who are illegal from coming into the city," he said.

Kansas Secretary of State Kris Kobach, a nationwide advocate for tougher illegal immigration laws who participated in the Farmers Branch case, said he was not surprised by Wednesday's ruling. Two of the three judges who heard the case last year indicated they opposed the city's law, Kobach said.