New York Times reporter Judith Miller told a grand jury yesterday about her conversations with Vice President Cheney's top aide in the summer of 2003, moving the two-year investigation into whether senior Bush administration officials illegally leaked covert CIA agent Valerie Plame's identity a step closer to its end.

Sources familiar with Miller's testimony say her account of two discussions with Cheney's chief of staff, I. Lewis "Scooter" Libby, that July are similar to the account Libby reportedly gave the grand jury last year. Both said they spoke about Plame's husband, administration critic and former ambassador Joseph C. Wilson IV, on July 8 and again on July 12 or 13. On at least one of those occasions, Libby told Miller that Wilson's wife worked at the CIA, the sources said.

Miller also turned over redacted copies of handwritten notes she made after one of the conversations with Libby, a condition set by special counsel Patrick J. Fitzgerald.

"I served 85 days in jail because of my belief in the importance of upholding the confidential relationship journalists have with their sources," Miller said after emerging from the courthouse after three hours of testimony. "Believe me, I did not want to be in jail."

Miller was the last person Fitzgerald sought to question in his investigation. The grand jury hearing the case is to conclude its work by Oct. 28. Barring some new development, legal experts predicted, Fitzgerald will soon wrap up his investigation.

Fitzgerald's probe has focused on contacts between administration officials and reporters in the days after July 6, 2003, when Wilson published an opinion piece undercutting the administration's justification for going to war with Iraq. Wilson alleged the government had "twisted intelligence" that he said he knew firsthand was dubious.

On July 14, Plame's name appeared in a column by Robert D. Novak, who reported that two confidential government sources had told him Wilson's wife helped arrange the trip he took to investigate claims that Iraq was trying to purchase uranium in the African nation of Niger for use in its nuclear weapons program.

Miller's testimony, which came after she served 85 days in jail trying to avoid such questions, focused the spotlight again on Libby. He is one of the administration's key policymakers, particularly in the area of foreign policy, and influenced internal administration debates over the decision to invade Iraq, the course of the Middle East peace process and negotiations over nuclear programs in Iran and North Korea.

Libby's conversations with reporters that July have consumed much of Fitzgerald's time. The top Cheney aide spoke with at least five reporters in the days after Wilson's public criticism, and several of them, including two at The Washington Post, have answered Fitzgerald's questions after working out agreements with their sources that allowed them to testify.

A sourceclose to Miller said yesterday that her testimony does not implicate Libby as intentionally and knowingly identifying Plame.

According to a source familiar with Libby's account of his July 2003 conversations with Miller, the two first met for breakfast on July 8, when Miller interviewed Libby about weapons of mass destruction in Iraq. At that time, she asked him why Wilson had been chosen to investigate questions that Cheney had posed about whether Iraq tried to buy uranium in Niger. Libby, the source familiar with his account said, told her that the White House was working with the CIA to learn more about Wilson's trip and how he was selected.

Libby had a second conversation with Miller, a telephone call on July 12 or July 13, the source said. In it, Libby said he had learned that Wilson's wife had a role in sending him on the trip and that she worked for the CIA. Libby never knew Plame's name or that she was a covert operative, the source said.

Miller never wrote an article on the matter.

As she stood on the courthouse steps yesterday, Miller, 57, refused to answer questions about her testimony but said she hoped her days in the Alexandria Detention Center would build support for laws to help reporters protect their confidential sources. She stressed that she was willing to testify only after Libby personally wrote her and telephoned her in jail to make it clear she was free to talk, and after Fitzgerald agreed to limit his questions to her conversations with Libby.

"I am hopeful that my very long stay in jail will serve to strengthen the bond between reporters and their sources."

Miller declined to answer questions on why she chose to accept Libby's waiver of confidentiality now. Libby's attorney, Joseph Tate, said he made it clear to Miller's lawyers a year ago that Libby was freely agreeing to allow her to testify about their conversations.

"Bear with me, I'm really tired," Miller said before her attorney Robert S. Bennett urged her to cut off questions from reporters. "I have a meal I want my husband to prepare, a dog I want to hug, and I'd like to go home to Sag Harbor."

Miller was released just before 4 p.m. Thursday after she complied with a judge's order to be interviewed by Fitzgerald and an FBI agent at the jail. Sources said the subject was similar to the questions she was asked before the grand jury. Fitzgerald's purpose was to be sure that Miller did not later contradict herself under oath.

Miller said her first "meal" outside jail was a "one-third of a martini in a gorgeous glass, along with a fruit tray," brought to her by New York Times Publisher Arthur O. Sulzberger Jr.

Miller was ordered to jail by U.S. District Judge Thomas F. Hogan on July 6 after she refused to testify. In court, Hogan told Miller that her source had already relieved her of her confidentiality pledge.

Friends of Miller's said Bennett, who joined her legal team earlier this year, urged giving up an absolutist position on whether to testify. Another lawyer, Floyd Abrams, had previously encouraged Miller's objections to cooperating. Bennett warned that Fitzgerald was a dogged prosecutor who was not likely to give up on Miller, the friends said, and had a good chance of convincing a judge to jail Miller for at least six more months.

But Abrams said in an interview yesterday that Fitzgerald made a recent and important compromise. The prosecutor would narrow his questions to Libby, which he had not been willing to do when Abrams approached him about the idea last year. Sources close to Miller said she had numerous government sources she wanted to protect, but Libby was the only one relevant to the Plame investigation.

In June 2004, Glenn Kessler, a Washington Post reporter, reached a similar agreement with the prosecutor to provide limited testimony that kept the substance of his conversations with Libby confidential, The Post reported at the time.

Fitzgerald declined to comment yesterday as he left the courthouse.

Time magazine reporter Matt Cooper avoided joining Miller in jail when he sought -- and received -- a personal waiver from his source on the story: White House adviser Karl Rove. Rove's attorney has said his client did nothing illegal when he told Cooper that Wilson's wife, without using her name, was in the CIA and authorized the mission to Niger. Rove also discussed the matter with Novak, according to a source familiar with Rove's account.