WASHINGTON — President George W. Bush sought to retroactively authorize portions of the National Security Agency’s post-9/11 surveillance and data collection program after a now-famous incident in 2004 in which his attorney general refused to certify the program as lawful from his hospital bed, according to newly declassified portions of a government investigation.

Mr. Bush’s effort to salvage the surveillance program without changes did not satisfy top Justice Department officials, who threatened to resign. But the newly disclosed passages of a report by inspectors general of six agencies suggest that the confrontation in the hospital room came after the Justice Department identified several problems, including a “gap” between what Mr. Bush had authorized the N.S.A. to collect and what the agency was collecting in practice.

A leak of government documents in 2013 revealed that the fight had been partly about the legality of the N.S.A.’s collection of data about Americans’ emails in bulk. But the latest disclosure shows that the Justice Department had additional concerns.

For example, Mr. Bush’s secret directives to the agency, starting in October 2001, said the N.S.A. could “acquire” phone and email metadata — logs showing who contacted whom, but not what they said — if at least one end was foreign or if a specific message were linked to terrorism. But the agency was apparently gathering purely domestic metadata in bulk, too, the Justice Department found.