WASHINGTON — The March 2004 confrontation in the hospital room of Attorney General John Ashcroft — a dramatic point in the Bush administration’s internal debate over warrantless surveillance — was apparently set off by a secret National Security Agency program that was vacuuming up “metadata” logs of Internet communications, according to a draft of a 2009 N.S.A. inspector general report obtained by the British newspaper The Guardian.

The report, the latest document given to the paper by the former N.S.A. contractor Edward J. Snowden, may clear up a long-running mystery over which program White House officials wanted Mr. Ashcroft and other Justice Department officials to sign off on when they went to his Washington hospital room. Because of their refusal, according to the report, the Bush administration shut down the metadata collection for several months, then re-established it under a secret order from a national-security court established by the Foreign Intelligence Surveillance Act, or FISA.