When Olympic gymnast McKayla Maroney came forward this fall with her story of being repeatedly molested by the team's doctor, USA Gymnastics publicly praised her for having the "courage" to hold a predator accountable.

But a lawsuit filed Wednesday by Maroney alleges that USA Gymnastics actually tried to silence her nearly a year earlier by making her sign a non-disclosure agreement as part of a financial settlement she needed to pay for psychological treatment.

Maroney's attorney, John Manly, called the confidentiality agreement "hypocritical, immoral and in this case illegal."

USA Gymnastics said in a statement that "the concept of confidentiality" was initiated by Maroney's attorney at the time of the settlement, Gloria Allred, who asked the organization to take part in a "confidential mediation process.”

Allred had no comment, but Manly said USA Gymnastics’ statement was “misleading.”

“Ms. Maroney did not want to enter into an agreement where she could not even speak to her brother and sister or friends about what happened to her. Under the terms of that agreement, she couldn’t even speak to a future fiancé without the threat of being sued,” he told NBC News.

“That agreement was written by USA Gymnastics lawyers, and it was designed to do one thing, which is keep their secret from the public.”

The agreement was inked just a few months after the first public accusations against Dr. Larry Nassar, who has since pleaded guilty to molesting 10 girls and possessing child pornography. At the time, law enforcement was encouraging women who were abused under the guise of treatments to come forward.

Maroney's suit, filed in Superior Court in California, alleges that USA Gymnastics insisted on a confidentiality agreement so "it could further conceal and shield from public scrutiny, outside investigation, and law enforcement, the true nature of Nassar's horrific sexual abuse of minors."

"Plaintiff alleges that Defendant USAG had a plan to keep the sexual abuse of Nassar quiet, and allow Nassar to quietly leave USAG, further silencing his victims," the suit charges.

Non-disclosure agreements are common in out-of-court settlements but have come under fresh scrutiny in recent months with revelations that alleged sex abusers and harassers including Bill Cosby, Bill O'Reilly and Harvey Weinstein used them to keep accusations under wraps and allow misconduct to continue.

Maroney's lawyer is seeking to have her released from the one she signed with USA Gymnastics, saying that in California, where the gymnast lives, a victim of child sexual abuse cannot be forced to sign an NDA as a condition of a settlement.

USA Gymnastics said the settlement did not break the law and noted that Maroney was represented by Allred, who practices in California.

The amount of the payout was not disclosed in the lawsuit, which said that Maroney is not trying to break the overall settlement at this point.

USA Gymnastics, which oversees the sport in the United States and selects the Olympic teams, had a two-decade relationship with Nassar until it quietly fired him after getting complaints from athletes in June 2015.

Although USA Gymnastics contacted the FBI about the 2015 complaints, it did not publicly raise any red flags about Nassar, who continued to treat, and allegedly abuse, patients at his Michigan State University sports medicine practice.

A private investigator for USA Gymnastics interviewed Maroney about her contact with Nassar in the summer of 2015, and the FBI interviewed her in the spring of 2016, according to a source familiar with the matter.

Allegations against Nassar did not become public until August 2016, when an Indianapolis Star investigation revealed two women, one a club-level gymnast and the other an elite athlete, had accused him of sexually assaulting them during invasive pelvic therapy.

Since then, more than 140 girls and women have filed complaints against Nassar. In October, Maroney became the highest-profile athlete to go public, posting on Twitter a harrowing account of abuse that allegedly occurred on three continents as Nassar traveled with the team.

"I had a dream to go to the Olympics, and the things that I had to endure to get there, were unnecessary, and disgusting," she wrote.

After her post — which was soon followed by allegations of abuse by fellow gold-medalists Aly Raisman and Gabby Douglas — USA Gymnastics praised Maroney.

"USA Gymnastics admires the courage of those, like McKayla Maroney, who have come forward to share their personal experiences with sexual abuse," the organization said in a statement.

"Because of their strength in coming forward, predators can be held accountable for their actions. We, like so many others, are outraged and disgusted by the conduct of which Larry Nassar is accused. We are sorry that any athlete has been harmed during her or his gymnastics career."

And when Maroney turned 22 earlier this month, USA Gymnastics applauded her again: "On her birthday, we celebrate not only the talent it took to deliver the best vaults in the World but also McKayla's incredible bravery and strength to come forward."

On her birthday, we celebrate not only the talent it took to deliver the best vaults in the World but also McKayla's incredible bravery and strength to come forward. pic.twitter.com/vrfJpfRJbx — USA Gymnastics (@USAGym) December 9, 2017

The lawsuit says that Maroney remains traumatized, gripped by depression and anxiety and terrified by the possibility that Nassar took photographs of her sexual abuse and shared them with other pedophiles.

"Nassar would continuously, obsessively and compulsively photograph McKayla Maroney and is believed to have possessed thousands of photographs of McKayla Maroney competing in gymnastics events, training, in everyday situations," the court papers say.

"McKayla Maroney alleges that she believes photographs were taken of her while Nassar was sexually abusing her under the guise of treatment. McKayla Maroney is further informed and believes, and on that basis alleges, that these photographs were shared by Nassar with other pedophiles for their sexual gratification.

"McKayla Maroney continues to worry, distress, experience concern, anxiety, and depression over whether Nassar's photographs of her are still circulating through the internet, and whether they are possessed by other pedophiles and sexual deviants, and whether she will ever know how widely these photographs have been shared or whether they will eventually surface later in her lifetime."

The lawsuit does not provide any evidence that explicit photos of Maroney were taken or shared, and federal prosecutors who seized thousands of pornographic images from Nassar did not indicate they found any images of his patients.

McKayla Maroney, Gabby Douglas and Aly Raisman, all members of the 2012 "Fierce Five" Olympics squad, say they have been molested by Dr. Larry Nassar. The White House / Getty Images

The suit, which says that Maroney lost out on millions of dollars because trauma drove her from the sport, seeks damages from USA Gymnastics, the U.S. Olympic Committee, Michgan State University and Nassar.

The institutions, it says, failed to act on previous complaints against Nassar and gave him unfettered, unsupervised access to Maroney and other victims.

The U.S. Olympic Committee said it played no role in the settlement or the non-disclosure agreement and is "heartbroken" that its athletes were preyed upon. MSU said it could not comment on pending litigation.

Nassar was sentenced this month to 60 years in federal prison on the pornography charges and is awaiting sentencing on state sex abuse charges. His attorneys did not respond to a request for comment.