The National Rifle Association cannot use bankruptcy to reorganize in gun-friendly Texas, a federal judge in Dallas ruled on Tuesday, handing a defeat to the influential firearms rights group that is facing an effort to dissolve it in New York state.

U.S. Bankruptcy Judge Harlin Hale's decision, following a trial over the legitimacy of the NRA's January bankruptcy filing, means the group will remain incorporated in New York.

Letitia James, New York's attorney general, had last August filed a lawsuit seeking the dissolution of the NRA, which she accused of corruption and misspending.

"The question the court is faced with is whether the existential threat facing the NRA is the type of threat that the Bankruptcy Code is meant to protect against," Hale wrote. "The court believes it is not."

Hale's dismissal is without prejudice, meaning the NRA can try again to file for bankruptcy, but the judge said the problems identified in its operations could result in the appointment of a trustee to oversee its affairs.

The NRA did not immediately respond to a request for comment.

Closely aligned with U.S. Republican politicians including former President Donald Trump, the NRA has been  instrumental for years in thwarting Democratic-backed gun control proposals in the U.S. Congress.

James, a Democrat, has accused the NRA of diverting millions of dollars to fund luxuries for officials including longtime Chief Executive Wayne LaPierre. She also accused it of awarding lucrative contracts to close associates and family members of senior officials.

LaPierre and the NRA have denied wrongdoing.

The NRA filed for Chapter 11 protection in January with the goal of reincorporating in Texas and escaping what it called a corrupt political and regulatory environment in New York.

James and the NRA's former advertising agency Ackerman McQueen have said the bankruptcy was filed in bad faith and to escape New York's oversight, with a lawyer for James during closing arguments of the trial calling the bankruptcy a "circus sideshow."

President Joe Biden's administration opposed the NRA in the trial. The Justice Department's bankruptcy watchdog, the U.S. Trustee, urged Hale to dismiss the bankruptcy.

The NRA has called New York's lawsuit politically motivated. LaPierre testified that he filed for Chapter 11 on behalf of the NRA because he feared James would try to put it into receivership.

The NRA also has faced internal upheaval in recent years including a failed effort to oust LaPierre over allegations of mismanagement.

The NRA was founded in 1871 in New York. Texas is a Republican-governed state whose leaders are friendly to the NRA's stance against gun control.

A spate of mass shootings in the United States this year prompted Biden in April to call gun violence "a national embarrassment." The Democratic president has taken some executive action on gun control and has called for broader steps that would require congressional passage including banning military-style assault weapons and large-capacity ammunition magazines.