WASHINGTON, Dec. 31 - A top Justice Department official objected in 2004 to aspects of the National Security Agency's domestic surveillance program and refused to sign on to its continued use amid concerns about its legality and oversight, according to officials with knowledge of the tense internal debate. The concerns appear to have played a part in the temporary suspension of the secret program.

The concerns prompted two of President Bush's most senior aides -- Andrew H. Card Jr., his chief of staff, and Alberto R. Gonzales, then White House counsel and now attorney general -- to make an emergency visit to a Washington hospital in March 2004 to discuss the program's future and try to win the needed approval from Attorney General John Ashcroft, who was hospitalized for gallbladder surgery, the officials said.

The unusual meeting was prompted because Mr. Ashcroft's top deputy, James B. Comey, who was acting as attorney general in his absence, had indicated he was unwilling to give his approval to certifying central aspects of the program, as required under the White House procedures set up to oversee it.

With Mr. Comey unwilling to sign off on the program, the White House went to Mr. Ashcroft -- who had been in the intensive care unit at George Washington University Hospital with pancreatitis and was housed under unusually tight security -- because "they needed him for certification," according to an official briefed on the episode. The official, like others who discussed the issue, spoke on the condition of anonymity because of the classified nature of the program.