Mr. Armstrong had undergone bypass surgery in early August 2012, and his wife told The Associated Press afterward that he was “amazingly resilient” and was walking in the corridor. But when nurses removed the wires for a temporary pacemaker, he began to bleed into the membrane surrounding the heart, leading to a cascade of problems that resulted in his death on Aug. 25.

In a scorching July 2014 email to the hospital’s lawyers, Wendy R. Armstrong, a lawyer and the wife of Mr. Armstrong’s son Mark, noted that Mark and his brother, Rick, would soon be traveling to Florida to speak at a ceremony marking the 45th anniversary of the first moon landing.

“This event at Kennedy Space Center will receive national news coverage,” Wendy Armstrong wrote. “Rick and Mark have been solicited by several book writers and filmmakers for ‘information about Neil that no one already knows.’” The lawyer suggested that unless the parties reached a quick settlement, the hospital would be publicly criticized for giving lethally flawed care to one of America’s most famous and revered public figures.

The medical dispute and secret settlement, never before reported, comes to light days after the 50th anniversary of Mr. Armstrong’s moon walk drew a flood of nostalgic coverage celebrating his feat. The New York Times received by mail from an unknown sender 93 pages of documents related to the astronaut’s treatment and the legal case, including dueling reports by medical experts for the two sides. Some of the documents, though marked “filed under seal,” are publicly available at the probate court’s website, confirming that the documents received by The Times are authentic. An unsigned note included in the envelope said the sender hoped the information would save other lives.

The legal settlement adds a grim footnote to the inspiring story of Mr. Armstrong, who avoided the limelight and never cashed in on his fame. It also illustrates the controversial but common practice of confidential settlements in medical malpractice and other liability cases, which protect reputations but hinder public accountability. And it shows how the extraordinary renown of a figure like Mr. Armstrong can become a powerful hammer in negotiations.