The woman who triggered the investigation that led to the resignation of CIA chief David Petraeus threw lavish parties for top military brass – and also racked up debt. NBC's Kristen Welker reports.

Then-CIA Director David Petraeus and Gen. John Allen, commander of U.S. and NATO troops in Afghanistan, intervened in a Washington, D.C., custody battle in September, writing letters on behalf of a woman who was found by a judge to have "severe personal deficits in the areas of honesty and integrity."

The woman, Natalie Khawam, is the twin sister of Tampa socialite Jill Kelley, who has emerged as a central figure in the scandal that led to Petraeus’ resignation last week.

The letters, which have been obtained by NBC News, were filed in court on behalf of Khawam, who the judge hearing the case harshly criticized for a “stunning willingness to say anything, even under oath, to advance her own interests.”

At the time, Khawam was seeking to relax a judge's order restricting her visits with her now 4-year-old son. Holly Petraeus, the wife of the ex-CIA director previously signed an affidavit in support of Khawam, according to the lawyer for Grayson Wolfe, Khawam's ex-husband. The letters were first reported by the New York Post.

Chip Somodevilla / Getty Images file Gen. John Allen, right, commander of U.S. and NATO forces in Afghanistan, and former CIA Director David Petraeus appear ath the White House on April 28, 2011.

The letters came to light after Kelley emerged as a key player in the scandal surrounding emails that officials say were written by Petraeus biographer Paula Broadwell – a trail of correspondence that led to Petraeus’ resignation as CIA director and a Pentagon investigation of Allen over what defense officials have described as “potentially inappropriate” emails he exchanged with Kelley.

The legal battle between Khawam and Wolfe has been bitter, according to court records. Both sides have accused one another of repeatedly lying to the court -- including about invitations to events involving prominent members of Congress.

The court records also shed some light on the lifestyle of the Kelley family: At one point, the judge -- who had directed Kelley's sister to pay child support and the legal fees of her ex-husband -- noted that Khawam lived "rent-free in Florida with her sister" in a home described as a "ten bedroom mansion in a beautiful neighborhood right on Tampa Bay."

The judge also ruled that Jill Kelley was a "patently biased and unbelievable witness" when she testified about an alleged case of domestic abuse by her twin sister's ex-husband.

In a Nov. 9, 2011, ruling, D.C. Superior Court Judge Neal E. Kravitz dismissed Kelley's testimony that she saw Wolfe push Khawam down a flight of stairs inside the Kelleys’ home. Kelley testified that her sister was holding the couple's baby in one hand and "somehow was able to stand her ground on the staircase" as Wolfe, "who is substantially larger and stronger ... pushed Ms. Khawam from above with both hands and all of his might."

Read David Petraeus' letter to the court

Read Gen. John Allen's letter to the court

"The court does not credit this testimony," Kravitz wrote, after calling Kelley an "unbelievable witness." He called it "part of an ever-expanding set of sensational accusations against Mr. Wolfe that are so numerous, so extraordinary and ... so distorted that they defy any common sense view of reality."

Amy Scherzer / Tampa Bay Times via Zuma Press Natalie Khawam, twin sister of Jill Kelley.

Petraeus and Allen entered the case two months ago, penning separate letters attesting to Khawam’s parenting.

"My wife and I have known Natalie for approximately three years, getting to know her while serving in Tampa, Florida, through her friendship with Dr. and Mrs. Scott Kelley," Petraeus wrote in his letter dated Sept. 20, identifying himself under his signature as "General, U.S. Army (Retired.) "

He added that he has observed Khawam with her son on many occasions, "including when we hosted them and the Kelley family for Christmas dinner this past year." It was "clear to me," he added, that Natalie's son "would benefit from much more time with his Mother and from removal of the burdensome restrictions imposed on her."

Allen's letter, dated Sept. 22, which identified him under his signature as "General, United States Marine Corps," is similar. It stated that he had gotten to know Khawam while serving at the U.S. Central Command in Florida and observed her with her son "on multiple occasions" at "command social functions."

"In light of Natalie's maturity, integrity and steadfast commitment to raising her child, I humbly request your reconsideration of the existing mandated custody settlement," the letter concluded.

Defense official fires back, denies Afghanistan commander exchanged 'inappropriate' emails

A source familiar with Kelley’s views said Tuesday night that both Petraeus and Allen have been friends of Kelley and her sister Khawam for years. The source added: “When you're involved in a custody issue, you want letters of support. There is nothing unusual about that.”

Sandra Wilkof, the lawyer for ex-husband Wolfe, said the letters from both high ranking military men misstated the facts of the case. Both letters asked the court to change the terms of a "court settlement" between the couple. In fact, Wilkof, said, "There was no court settlement. There was a court order," she said, awarding custody to Wolfe and supervised visits for Khawam.

Slideshow: Petraeus case: Cast of characters ISAF via Reuters file Meet the people who have been pulled into the scandal that caused Gen. David Petraeus to resign. Launch slideshow

Judge Kravitz has not given Wolfe a free pass. He wrote in the Nov. 9, 2011 ruling that Wolfe "does not possess an entirely healthy psychological make-up.” And he noted that Wolfe had taken “questionable deductions” on his tax returns and “may have been less than fully candid in his testimony about contacts he may have had with the FriendFinder online dating service.”

But he has saved his harshest words for Khawam, writing that “Mr. Wolfe … is much more honest than Ms. Khawam, and he conducts himself with far greater integrity.”

In the ruling, he found that Khawam had taken the couple's son to Florida when he was only four months old and refused to tell Wolfe of his whereabouts, ignored court orders to allow visits with his father, changed the boy's first name without his father's knowledge and made unfounded claims of abuse against her ex-husband.

"The evidence established that Ms. Khawam has extreme personal deficits in the areas of honesty and integrity," Kravitz wrote. "Ms. Khawam's false domestic violence petitions (and her equally false testimony at trial relating to many of the same allegations) are merely the most stunning examples of Ms. Khawam's willingness to say anything, even under oath, to advance her own personal interests at the expense of Mr. Wolfe, the child, and others."

Khawam's lawyer, Greg Jacob, with the law firm of O'Melveny & Myers, did not respond to requests for comment.

In the latest wrinkle in the case, Wolfe's lawyer filed a motion on Oct. 26 opposing the efforts of Khawam to modify the visitation schedule, saying that neither of the letters by Petraeus and Allen promised “corroborating testimony” relevant to the court's determination.

The motion also argued that Khawam had misrepresented social events she had asked the court to let her attend with her son. In one case, Wolfe's motion stated, Khawam had asked the court to let her take her son to a "family clambake" at "the personal invitation" of Rhode Island Sen. Sheldon Whitehouse. In fact, the motion states, this was "nothing more than a … political fundraising event."

On other occasions, the motion states, Khawam had sought to take her son to events with "Senator Kerry" and the baptism of "former Congressman Patrick Kennedy's child" in New Jersey. In fact, the motion states, the invitation to be with Sen. John Kerry was a Democratic Senatorial Campaign Committee event in Martha's Vineyard and that he denied her request to take the boy to those events because he did not believe it was in "the child's best interests."

More from Open Channel:





Follow Open Channel from NBCNews.com on Twitter and Facebook