A federal judge ordered New York Times reporter Judith Miller to the Alexandria jail yesterday after she again refused to cooperate in an investigation of whether senior administration officials leaked a CIA operative's name in retaliation against an administration critic.

In a last-minute surprise, Time magazine reporter Matthew Cooper avoided Miller's fate by agreeing in the same court hearing to cooperate with special prosecutor Patrick J. Fitzgerald's probe.

Cooper told the judge that he said goodbye to his 6-year-old son yesterday morning and was expecting to go to jail for as long as four months. But minutes later he received a surprise phone call from his government source, who, Cooper said, freed him to break their confidentiality agreement and to tell a grand jury about their conversations in July 2003.

It was a showdown of national proportions, with a mild-mannered chief judge of one of the most important trial courts in the country pitted against high-profile reporters for prominent national news organizations. In the past 20 years, 18 reporters have been jailed for refusing to identify sources or to turn over information, according to press advocacy groups, but most were involved in local disputes between a reporter and a district attorney in the midst of a criminal trial.

This battle centered on questions about President Bush's justification for taking the country to war, the reputations of two top media organizations, and allegations that someone in a bitter White House broke the law to strike back at a public critic.

It also posed painful questions for the press about whether journalists have falsely assumed that they have an absolute legal right to promise anonymity to sources. Ultimately, the case even led to a philosophical rift within the Fourth Estate, with Time magazine yielding to Chief U.S. District Judge Thomas F. Hogan's order to turn over Cooper's reporting notes and Times editors saying the magazine was wrong to do so.

Hogan said Miller was mistaken in her belief that she was defending a free press. He stressed that the government source she "alleges she is protecting" had already waived her promise of confidentiality. He said her source may have been providing information not to shed light on government secrets but to try to discredit an administration critic.

"This is not a case of a whistle-blower" revealing secret information to Miller about "dangers at a nuclear power plant," Hogan said. "It's a case in which the information she was given and her potential use of it was a crime. . . . This is very different than a whistle-blower outing government misconduct."

Miller told Hogan that if she broke her promise to one confidential government source, other sources would no longer come forward, and the public would inevitably learn less about what the government is doing.

"I know that the freest and fairest societies are those with a free press . . . publishing information that the government does not want to reveal," she said. She compared her effort to that of U.S. troops risking death in their fight for freedom in Iraq: "If they can do that, surely I can face prison to defend a free press."

Times Publisher Arthur O. Sulzberger Jr. released a statement saying that "there are times when the greater good of our democracy demands an act of conscience. Judy has chosen such an act in honoring her promise of confidentiality to her sources."

Fitzgerald has been investigating for 18 months whether senior Bush administration officials broke the law by knowingly leaking the identity of covert CIA operative Valerie Plame to reporters as retaliation for an opinion piece written by her husband. Plame's name first appeared in a syndicated column by Robert D. Novak in July 2003, eight days after her husband, former ambassador Joseph C. Wilson IV, accused the administration of twisting intelligence to justify war with Iraq. Wilson led an earlier mission to Niger to investigate allegations that Iraq was trying to buy uranium for nuclear weaponry, and he concluded they were unfounded.

Hogan found Miller, Cooper and Time in contempt of court last October for defying his order to cooperate in Fitzgerald's investigation. Their appeals of his order were exhausted last month when the Supreme Court refused to hear the case, sending the case back to Hogan.

Miller was led out of the courtroom well by two U.S. marshals through a backdoor exit to a holding cell for processing. Before leaving, she handed her gold necklace to her husband, hugged her two attorneys and waved goodbye to a small cluster of friends in the court. She could be jailed until Oct. 28, when the term of the investigating grand jury expires.

Her attorney, Robert Bennett, said Miller may be the only one jailed in an investigation focused on government leaks. He called it an "absolute tragedy."

But Hogan disagreed: "I don't understand how this is a tragedy. It is Ms. Miller's choice. She has the keys to release herself. . . . She has a waiver she chooses not to recognize."

The dramatic sight of a reporter being led off to jail, however, spurred many journalists and free-press advocates to warn that reporters, especially those covering the White House and national security issues, will find it much harder to obtain accurate information about government operations. Press advocates and lawmakers said that yesterday's events proved the need for a new federal shield law to protect journalists against the release of information about confidential sources.

"It's the mother of all chilling effects," said longtime media lawyer Charles Tobin. "There can't be any stronger statement to journalists and their sources that the law won't stand behind them."

John F. Sturm, president and chief executive of the Newspaper Association of America, said confidential sources have revealed major safety violations at nuclear plants, corporate fraud and other vital information. "Without the promise of confidentiality, sources, including whistle-blowers, will not come forward," he said.

Hogan disputed assertions that jailing Miller would bring good reporting to a halt. He noted that the Supreme Court ruled in Branzburg v. Hayes in 1972 that reporters do not have a right to protect confidential sources in criminal investigations.

"Branzburg has been the law for 33 years and it hasn't stopped anything . . . including Watergate," Hogan said.

But his order prompted some hand-wringing among reporters and media experts about whether the New York Times and Time magazine helped or hurt the cause of a free press by fighting a less-than-sympathetic case all the way to the Supreme Court -- and losing.

Yesterday, New York Times Executive Editor Bill Keller answered that complaint by telling reporters outside the courthouse that the paper felt it did not have much choice.

"To paraphrase Donald Rumsfeld . . . you go to court with the case you have," Keller said. "It's not the ideal case for anybody."

Tobin agreed: "I don't think reporters feel like they get to pick and choose which sources to protect and which ones to throw under the bus."

Cooper told reporters who congratulated him as he left the court that he did not feel lucky.

"There's no congratulations here," he said. "It's a very sad day . . . when journalists just doing their jobs face the prospect of jail."

Cooper declined to identify the government source who called and freed him to speak to the grand jury and Fitzgerald about their conversations in 2003.

One of the government officials Cooper talked to during that period was Karl Rove, Bush's chief political adviser, according to Cooper's notes and Rove's attorney, Robert Luskin. Luskin has said that Rove did not identify Plame to Cooper and did nothing wrong.

In an interview yesterday, he said Rove was not the source who called Cooper yesterday morning and personally waived the confidentiality agreement.

"Karl has not asked anybody to treat him as a confidential source with regard to this story," Luskin said.

Wilson released a statement yesterday saying that Miller has joined his wife as the "collateral damage" of a White House effort to smear him. He said Bush has not done much since he insisted in 2003 that the administration "get to the bottom" of the leak.

"Clearly, the conspiracy to cover up the web of lies that underpinned the invasion of Iraq is more important to the White House than coming clean on a serious breach of national security," he said.

New York Times reporter Judith Miller arrives at the U.S. District Court with her attorney, Robert Bennett, left. She was sent to jail for refusing to reveal the identity of a source in the case of a leak about a CIA operative.Time magazine reporter Matthew Cooper, left, with attorney Richard Sauber, agreed to testify after his source canceled their agreement.Matthew Cooper of Time magazine is surrounded by fellow journalists as he enters the U.S. District Court in Washington.

Judith Miller of the New York Times prepares to enter the courthouse with her attorney, Robert Bennett, left. She was sent to jail in Alexandria.

Time magazine's Matthew Cooper leaves the courthouse after the hearing.

A reprieve from his source allowed him to cooperate with the investigation.