The chief executive of the National Rifle Association and several top lieutenants engaged in a decades-long pattern of fraud to raid the coffers of the powerful gun rights group for personal gain, according to a lawsuit filed Thursday by the New York attorney general, draining $64 million from the nonprofit in just three years.

In her lawsuit, Attorney General Letitia James called for the dissolution of the NRA and the removal of CEO Wayne LaPierre from the leadership post he has held for the past 39 years, saying he and others used the group’s funds to finance a luxury lifestyle.

She also asked a New York court to force LaPierre and three key deputies to repay NRA members for the ill-gotten money and inflated salaries that her investigation found they took.

James accused the NRA leaders of flouting state and federal laws and signing off on reports and statements they knew were fraudulent, while diverting millions of dollars away from the NRA’s charitable mission to benefit themselves and their allies.

The attorney general requested that the court bar the four men — LaPierre, general counsel John Frazer, former treasurer Woody Phillips and former chief of staff Joshua Powell — from ever serving in a leadership position for a New York charity in the future.

“The NRA’s influence has been so powerful that the organization went unchecked for decades while top executives funneled millions into their own pockets,” James, a Democrat, said in a statement.

Her investigation, which began in February 2019, found “a culture of self-dealing, mismanagement, and negligent oversight at the NRA that was illegal, oppressive, and fraudulent,” according to a statement by the attorney general’s office.

The scope of the allegations by the New York attorney general come as a serious blow to the longtime political powerhouse and a top ally of President Trump, which is planning to again spend millions this fall on behalf of him and other Republican candidates.

NRA officials lashed back in response, accusing James in a countersuit of a premeditated plan to take down the organization.

In a tweet, Trump accused the “Radical Left New York” of “trying to destroy the NRA.”

Meanwhile, D.C. Attorney General Karl A. Racine announced Thursday that his office filed a separate lawsuit against the NRA Foundation, which is based in Washington. Racine accused the organization of being a puppet of the NRA, despite legal requirements that it independently pursue charitable purposes. Instead, Racine said his office found, the foundation repeatedly lent the NRA money to address its rising deficits.

James said at a news conference Thursday that she is seeking to dissolve the NRA because of the brazenness of the group’s violations of law.

“The corruption was so broad, and because they have basically destroyed all the assets of the NRA,” she said. “Enough was enough. . . . No one is above the law, not even the NRA.”

Her office cited as a precedent its previous action against the Trump Foundation, which led Trump to shut down the charity in 2018 amid allegations he used it for his personal benefit.

The New York lawsuit against the NRA paints a picture of widespread wrongdoing at the influential gun rights group, and a freewheeling atmosphere in which top officials repeatedly took advantage of their positions for their personal benefit.

In one new revelation, the attorney general said her investigation uncovered that LaPierre recently arranged a post-employment contract for himself with the NRA worth $17 million. He never sought board approval for the deal, the suit claims.

The lawsuit also claims LaPierre failed to report large sums of personal income to the IRS. James’s office said it found that the NRA chief funneled personal expenses through an outside public relations firm, allowing him to avoid reporting hundreds of thousands of dollars of personal income.

James said Thursday that she was referring those findings to the IRS. She also said that if her office uncovers criminal activity, it will be referred to the Manhattan District Attorney’s Office.

In response, the NRA said Thursday that it was filing its own federal lawsuit against James, alleging that the attorney general has violated the group’s free-speech rights and has been unfairly targeting the gun rights lobby since she began campaigning for the office.

“The NYAG’s actions are an affront to democracy and freedom,” LaPierre said in a statement late Thursday. “This is an unconstitutional, premeditated attack aiming to dismantle and destroy the NRA — the fiercest defender of America’s freedom at the ballot box for decades. The NRA is well governed, financially solvent, and committed to good governance. We’re ready for the fight. Bring it on.”

NRA officials said they believe James’s action was designed to disrupt the group’s momentum at a critical time in the 2020 election campaign. The NRA political action arm plans to spend tens of millions of dollars this fall to mobilize its members to defeat Democratic candidates who seek gun restrictions, including putative Democratic presidential nominee Joe Biden, according to a person familiar with fundraising, who spoke on the condition of anonymity to describe internal strategy.

The NRA Political Victory Fund, the group’s political action committee, raised $16.8 million through Aug. 4, according to the nonpartisan Center for Responsive Politics. That compares with $21.6 million raised by the PAC in all of 2016.

“It’s a transparent attempt to score political points and attack the leading voice in opposition to the leftist agenda,” NRA President Carolyn Meadows said in a statement. “This has been a power grab by a political opportunist — a desperate move that is part of a rank political vendetta.”

Trump also decried the legal action against the organization, which spent millions on his behalf in 2016, calling it a “terrible thing” as he spoke to reporters Thursday morning at the White House. He said the NRA had been “decimated” by legal expenses and suggested the group should move from New York to Texas.

For their part, advocacy groups that seek gun restrictions said they welcomed the action against the powerhouse gun lobby.

“Thoughts and prayers today to the NRA, which is losing money and political power so quickly that by the end of this case, there might not be anything left to dissolve,” said Shannon Watts, founder of Moms Demand Action.

Experts in tax law said the deep investigation into the NRA’s finances showed the potential for state officials to vigorously enforce nonprofit rules.

“It is a watershed moment in nonprofit regulation,” said Douglas Varley, who advises nonprofit organizations at the law firm of Caplin & Drysdale.

With a decline in IRS funding and enforcement, there has been a widespread belief that “the locus of nonprofit enforcement is shifting from IRS to the states,” Varley said. “Here is the clearest possible evidence of that reality. I think everyone who believes a strong regulator is needed would heartened by this.”

The dual suits filed by the attorneys general in New York and Washington punctuate nearly two years of infighting at the NRA over management of the group’s funds, a civil war that led to the exodus of many veteran members and top officials.

Longtime NRA member Rob Pincus, a critic of LaPierre’s leadership, said Thursday in a statement that “none of us who have been pushing for NRA reform are celebrating today’s announcement.”

“It is tragic that the NY AG’s office is having to step in to clean up the NRA,” he added.

The group’s bitter internal battle burst into public view in April 2019 at the NRA’s annual convention in Indianapolis, when then-NRA President Oliver North was forced out by LaPierre after pressing for an internal financial review.

The Washington Post and other news organizations subsequently revealed how the NRA directed funds to board members and how LaPierre racked up hundreds of thousands of dollars in charges at a Beverly Hills clothing boutique and on foreign travel.

The Post also reported how, after a mass shooting at a high school in Parkland, Fla., LaPierre told close associates he was worried about how easily he could be targeted and needed a more secure place to live and sought to buy a $6 million, 10,000-square-foot French-style country estate in Westlake, Tex.

The suit expands on previous allegations that LaPierre improperly charged the NRA for private jet travel and luxury vacations that had no clear business purpose. The filing claims he billed the NRA more than $500,000 for private charter flights he and his family took to visit the Bahamas eight times over three years.

Last year, a spokesman for LaPierre told The Post his visits to the Bahamas were for NRA business. But the New York attorney general’s investigation found the trips were private vacations.

In four years, LaPierre was reimbursed by the NRA for $1.2 million in expenses that were personal trips, golf fees and gifts, the suit contends.

LaPierre also spent $3.6 million of NRA money for private travel consultants to arrange private jets and executive car service for his and his family’s use over just two years, the suit says. And he set aside several million dollars each year for private security for him and his family.

In addition, LaPierre enjoyed the largesse of NRA vendors who hoped to keep the organization’s business, the suit says. One vendor gave LaPierre and his wife an all-expense-paid trip to Africa for a safari adventure; another frequently lent LaPierre and his family the use of his 107-foot yacht on his visits to the Caribbean.

Phillips, the former treasurer, is accused in the suit of arranging an NRA deal worth more than $1 million that benefited his girlfriend. The lawsuit also claims that shortly before he retired in 2018, Phillips obtained a contract for himself worth $1.8 million. The contract called for him to provide advice and consulting services for the new treasurer, but the new treasurer said he knew nothing of the contract and never received any services from Phillips, the suit contends.

Phillips did not immediately respond to a request for comment.

Powell, LaPierre’s former chief of staff, had his salary increased from $250,000 to $800,000 in just three years as a reward for his loyalty to LaPierre, the suit states, and allegedly pocketed an additional $100,000 he was not entitled to as a housing allowance. In addition, the complaint alleges, Powell arranged for his wife and father to earn money through NRA contracts.

In a statement, an attorney for Powell said he was fired by LaPierre for attempting to correct much of the misconduct James reported in her lawsuit, noting that Powell’s compensation was approved by the NRA’s general counsel and his business-related expenses were approved.

“When the NRA’s lawyers later complained about those expenses, he submitted his check in payment of the disputed amount,” the statement said. “Mr. Powell is confident that — once all the facts are known — the allegations directed at him in this lawsuit will be shown to be the result of false accusations made by Wayne LaPierre and others in their efforts to prevent disclosure of the wrongdoing Mr. Powell sought to correct and to extract themselves from the Attorney General’s investigation.”

The lawsuit accuses Frazer, general counsel to the NRA, of failing to make sure the nonprofit was governed properly and followed state and federal laws, and it claims he certified false or misleading annual statements.

James said Frazer failed to comply with the rules on board governance, to make sure the board was aware of and voting on major financial transactions and to follow the NRA’s conflict-of-interest policy.

In its lawsuit Thursday, the NRA accused James of conspiring with Everytown for Gun Safety, a gun-control organization backed by former New York mayor Mike Bloomberg that has investigated the group’s finances.

The group’s president, John Feinblatt, said the investigation vindicated Everytown’s work.

“Even casual observers of the NRA have seen it turn from a safety-focused nonprofit into a front group for gun manufacturers and a personal piggy bank for its leadership,” Feinblatt said.

A central fraud embedded in NRA finances, James’s suit claims, was a secret agreement to pass questionable expenses through its Oklahoma-based advertising agency, Ackerman McQueen.

Under that agreement, the suit alleges, LaPierre and his inner circle of trusted deputies rerouted millions of dollars in lavish personal expenses for themselves, their families and allies through Ackerman McQueen. The goal was to avoid having the board or other members of the NRA know that the charitable organization was paying so much money for LaPierre’s membership fees at golf clubs, private jet travel and designer suits, the lawsuit says.

The agency then billed the NRA for these large, unexplained sums, calling them “out-of-pocket” expenses, suggesting they were related to the company’s advertising work for the NRA.

The attorney general’s office said it found that Ackerman McQueen billed the NRA $70 million in just 2017 and 2018 for its public relations work, including “out-of-pocket” expenses.

A very large portion of those hidden expenses were for personal trips and expenses for LaPierre, the New York suit contends. In a deposition in a separate lawsuit last year, LaPierre acknowledged he did not report any of the NRA-paid expenses as personal income to the IRS and claimed they were business expenses.

In its statement, the attorney general’s office said that practice “did not comply with IRS requirements, and, as a result, all such expenses should have been included by the NRA in taxable personal income for LaPierre.”

Ackerman McQueen said in a statement that LaPierre claimed to the firm that all his expenses were for business purposes. The company, which said that it is cooperating with the attorneys general of New York and Washington, added that after it stopped the reimbursement practice in 2018, LaPierre “initiated an orchestrated scheme to remove Ackerman McQueen as an NRA vendor.”

The partnership between the NRA and the public relations firm began to crack after James, then a candidate for New York attorney general, announced in summer 2018 that she planned to launch an investigation into the NRA if she won. LaPierre hired a new law firm, led by then-Ackerman McQueen chief executive Angus McQueen’s estranged son-in-law. That attorney, Bill Brewer, urged that the NRA to audit Ackerman McQueen’s bills in preparation for James’s probe.

At LaPierre’s direction and with Brewer’s help, the NRA ejected its in-house lawyer and sued Ackerman McQueen, accusing the firm of concealing details of the nearly $40 million the NRA paid it each year.

Last spring, North announced in Indianapolis that he would not seek a second term as president, warning about exorbitant payments to Brewer’s firm and reports of financial mismanagement.

“There is a clear crisis,” North said in his letter announcing his departure.