WASHINGTON — The federal government has agreed to pay $2.5 million to the widow and children of the first person killed in the anthrax letter attacks of 2001, settling a lawsuit claiming that the Army did not adequately secure its supply of the deadly pathogen.

The settlement with the family of Robert Stevens, a tabloid photo editor in Florida, follows an eight-year legal battle that exposed slack rules and sloppy recordkeeping at the Army’s biodefense laboratory at Fort Detrick, in Frederick, Md. As part of the agreement, Justice Department lawyers are seeking to have many documents that were uncovered in the litigation kept under court seal or destroyed.

Mr. Stevens’s widow, Maureen, filed suit against the government in 2003, as evidence accumulated that the anthrax powder in the lethal letters had come from an Army laboratory. The F.B.I. finally concluded in 2008 that the letters were sent by Bruce E. Ivins, a microbiologist who worked on anthrax vaccines at the Army lab in Maryland, though some of his colleagues and friends have maintained that he was innocent.

Dr. Ivins killed himself in 2008 as prosecutors prepared to indict him in the attacks, in which letters were sent to media organizations and two senators in September and October of 2001, killing five people and sickening at least 17 others. The letters prompted fear nationwide, forced members of Congress and the Supreme Court from contaminated buildings and set off a long and troubled investigation by the F.B.I.