BROWNSVILLE, Texas (CN) – Weary of flooding toilets and rats, inmates rioted and shut down a South Texas federal immigration prison, costing 400 locals their jobs, a Texas county claims in a lawsuit against a prison-management firm.

The Willacy County Local Government Corp., a quasi-governmental body the county formed to take out $65 million in bond debt to fund construction of a prison complex in Raymondville, the county seat, sued Management & Training Corp. on Wednesday in Brownsville, Texas federal court.

Utah-based Management & Training Corp., also called MTC, is a privately owned prison-management firm that says on its website it “safely secures more than 75,000 offenders and detainees in eight states at 25 facilities annually.”

Raymondville is about 50 miles north of the Mexico border. The prisoners who rioted in February 2015 were undocumented immigrants slated for deportation once they served federal criminal sentences, according to a May 2015 story by the Texas Observer.

Willacy County says in its nine-page lawsuit that Hale-Mills Construction Ltd., a “multibillion-dollar government contractor,” approached county officials in 2002 about constructing several buildings to house state and federal prisoners and deportation detainees.

“Hale-Mills’ pitch was that the county would be paid for housing these inmates and detainees. The pay was promised to be sufficient not only to recoup the $65 million investment, but also to produce substantial net income to the county,” the complaint states.

With the county struggling financially due to a drop in revenue from a declining farming industry, it contracted with Hale-Mills in July 2006 to build the Willacy County Correctional Center in Raymondville, according to the complaint and the Observer.

The county hired MTC to run the prison in July 2006 and renewed the contract five times. The last renewal was in July 2011, the county says.

MTC also initially contracted with U.S. Immigrations and Customs Enforcement to detain immigrants at the prison who were facing the civil penalty of deportation for being caught in the country without authorization or awaiting hearings on their immigration status.

But ICE reportedly canceled its contract with MTC in 2011 and the U.S. Bureau of Prisons contracted MTC to detain immigrants set for deportation once they served their federal criminal sentences, many for illegally entering the United States.

Illegal entry is a misdemeanor punishable by up to six months in federal prison and a $250 fine.

Under its contract with the county, MTC paid for the prison staff and for food, laundry, educational, medical and counseling services for the inmates, and the county agreed to reimburse more than $2 million of those costs.

“MTC had the duty to preserve and keep the prison in good repair, working order, and condition, subject to normal wear and tear, and make or cause to be made all necessary and proper repairs. As part of this provision and upon notification, the county agreed to bear the cost of repair,” the lawsuit states.

But MTC “turned a blind eye” to maintenance issues from the start, the county says.

“Problems with flooding toilets, water seeping underneath the property, rodents, and lack of access to basic inmate services plagued the facility on MTC’s watch…Further, MTC failed to address the issue of prison overcrowding, presumably because MTC was paid an additional per diem for inmates beyond the 90 percent capacity threshold,” the complaint states.

MTC put 200 prisoners’ beds only 3-feet apart under each of 10 huge Kevlar tents, which gave the prison its nickname “Tent City,” according to the Observer.

The county says in its lawsuit the grim living conditions sparked a prisoner riot on Feb. 20, 2015.

Prisoners reportedly set three tents on fire, broke toilets and destroyed surveillance cameras.

“Ultimately, the prison was forced to close and declared ‘uninhabitable’ by the BOP due to MTC’s failure to meet its most basic contractual obligations. All 400 employees of the prison lost their jobs,” the complaint states.

Despite the lawsuit’s allegations of mismanagement, an MTC spokesman said the prison passed all its federal audits before the riot.

“The Bureau of Prisons monitored MTC’s operation on a daily basis and did frequent comprehensive audits to make sure the facility was safe and clean and that it met all federal BOP standards,” Issa Arnita, MTC’s communication director, said in a statement.

Willacy County seeks damages for claims of breach of contract, negligence and fraudulent inducement. It is represented by Bruce Steckler with Steckler Gresham Cochran in Dallas.

The prison’s closure has exacerbated a problem the federal government has with finding space to detain an influx of Central American immigrants, who experts say are fleeing poverty and gang violence in their native countries and turning themselves in to U.S. immigration authorities with hopes of getting asylum in the United States.

“In October a total of 46,195 individuals were apprehended between ports of entry on our southwest border, compared with 39,501 in September and 37,048 in August,” the Department of Homeland Security said in a Nov. 10 statement.

To deal with the influx of Central American families, U.S. Customs and Border Protection is “standing up a temporary holding facility” with space for up to 500 people near the Donna Texas Port of Entry, the agency said last month.