A federal judge in Texas has thrown out the National Rifle Association’s bankruptcy petition, ruling that the gun-rights group’s Chapter 11 filing was intended to evade a lawsuit from New York’s attorney-general.

Judge Harlin Hale wrote in Tuesday’s decision that the bankruptcy case had not been brought “in good faith”, both “because it was filed to gain an unfair litigation advantage and because it was filed to avoid a state regulatory scheme”.

The NRA bankruptcy, filed late on a Friday in January, came as a shock to observers, as there were few inklings of any immediate financial difficulties at the prominent gun lobby, led by Wayne LaPierre, its chief executive and executive vice-president.

It came several months after Letitia James, New York’s progressive attorney-general, sued the NRA in state court, seeking to break it up. The state had argued that the gun lobby had been used as a personal piggy bank by its leadership, including LaPierre.

At the time of the Chapter 11 petition, LaPierre wrote in a public letter: “The plan can be summed up quite simply: We are DUMPING New York, and we are pursuing plans to reincorporate the NRA in Texas.” LaPierre later noted that the NRA was “as financially strong as we have ever been in years”.

James asked the bankruptcy court to dismiss the case. Some other NRA stakeholders had sought to have a third-party examiner or trustee appointed.

During an 11-day trial in the Texas bankruptcy court to decide whether to dismiss the petition, details of the business practices of the NRA and LaPierre were exposed, some of which the court described as “cringeworthy”.

Hale wrote that he was troubled that the bankruptcy filing had been engineered by LaPierre with little input or knowledge of other NRA leaders.

He wrote that “excluding so many people from the process of deciding to file for bankruptcy, including the vast majority of the board of directors, the chief financial officer, and the general counsel, is nothing less than shocking”.

Hale acknowledged in his decision that the group was “financially healthy” and that creditors were likely to be paid back more quickly outside of a court-supervised reorganisation.

James wrote on Twitter on Tuesday afternoon that she would continue to pursue the NRA in state court: “The NRA does not get to dictate if and where it will answer for its actions . . . No one is above the law.”

“Given that the bad faith was manifest from the get-go, one has to wonder what on earth the NRA was possibly thinking with the bankruptcy strategy,” said Adam Levitin, a law professor at Georgetown who has followed the case.

He added: “That said, the remedy — dismissal without prejudice — is the least bad outcome.

“LaPierre remains in control of the NRA, which he would not have, had the court not dismissed the case, but appointed a trustee.”