President Bush intervened in March 2004 to avert a crisis over the National Security Agency’s domestic eavesdropping program after Attorney General John Ashcroft, Director Robert S. Mueller III of the F.B.I. and other senior Justice Department aides all threatened to resign, a former deputy attorney general testified Tuesday.