Former defense secretary Robert S. McNamara -- in a sometimes emotional, sometimes combative day on the witness stand -- denied today that he had portrayed American chances of winning the Vietnam war differently to the public and Congress than to President Lyndon B. Johnson.

Testifying on behalf of retired general William C. Westmoreland in his libel suit against CBS Inc., McNamara said that after recently rereading most of 4,000 pages of his unclassified statements in 1967 and 1968 he found "considerable evidence" that his reports to the president were consistent with his reports to Congress and the public.

"I did not believe I expressed a different judgment to Congress than the one I expressed to the president on the progress of the war," he told a packed courtroom in Manhattan's federal court.

"And is the same thing true with respect to your statements to the public, that is, you were conveying to the public in your public statements the same view that you were conveying to the president?" CBS lawyer David Boies asked.

"I believe so," McNamara responded.

The former Cabinet secretary to Presidents John F. Kennedy and Johnson has shied away from public statements about his views on U.S. chances of winning in Vietnam. But today Boies was able to engage him in a long session comparing his various public and private statements during a crucial period of the war.

It was one of the more dramatic days in a trial that has narrowed steadily over the past nine weeks to the issue of whether Westmoreland deceived his superiors by refusing to endorse new enemy troop figures given him in May 1967.

But the brief broadening of the trial to questions about how U.S. leaders at the time managed the war almost did not happen.

U.S. District Court Judge Pierre N. Leval allowed McNamara's extended testimony -- which Westmoreland's attorneys called an irrelevant diversion -- because of a misstep by the general's key lawyer, Dan M. Burt. Burt clearly intended to have McNamara on the stand only briefly as a character witness for Westmoreland, but he inadvertently asked a question about areas related to the war.

Burt tried to close off further questions, but the judge told him: "I'm afraid, Mr. Burt, that while you may have opened the door for only a very brief few seconds, in a few seconds the door can be opened rather wide."

Invited to move into that new territory, CBS lawyer Boies then drew out the former defense secretary on why he told a Senate committee in August 1967 that Vietnam was "not a no-win program," even though he had been saying privately that the war could not be won militarily.

The reason, McNamara said, was that he believed that the war could be ended diplomatically.

McNamara said that during 1967 secret peace feelers had been made to North Vietnamese leader Ho Chi Minh through Henry A. Kissinger, who then was a Harvard University professor advising the Johnson administration and later became President Richard M. Nixon's secretary of state.

"Henry Kissinger, acting as a private citizen, had served as an intermediary with two Frenchmen through whom we were negotiating directly with Ho Chi Minh," McNamara said. "That was a political track that was under way at the time."

McNamara, who has said he was disturbed to learn that an affidavit he signed on Westmoreland's behalf more than two years ago made him legally available to testify, seemed nervous as he began his day on the stand.

Asked by Burt for an opinion of Westmoreland, who differed with the former defense secretary over the war's progress in those years, McNamara began: "My opinion then, and today, was that he is a person of tremendous integrity."

Then, his voice breaking for a moment, McNamara added that Westmoreland was also a man "with whom I had major policy disagreements, a person who served his country well, and whom I have the highest regard for."

Later, apparently regaining some of the authoritativeness that characterized him as defense secretary and later as World Bank president, McNamara began challenging the CBS lawyer until at one point the judge chastised him about debating from the witness stand.

McNamara, denying that he promoted the war publicly while privately saying it could not be won, said repeatedly during the day that he was at odds with Westmoreland and the Joint Chiefs of Staff about the war's progress and that when he issued optimistic pronouncements in this period they were attributed to the Joint Chiefs of Staff.

Asked during the August 1967 hearing by Sen. Henry M. Jackson (D-Wash.) about Jackson's concern that "I can't see any kind of light at the end of the tunnel . . . ," McNamara answered that each of the joint chiefs "believes that we are winning and will continue to win."

In the courtroom today, he elaborated that the joint chiefs had told the hearing that "we should be doing more bombing.

"They were unanimous in believing that the bombing was effective. But this poor, inexperienced civilian didn't know what the hell was going on and had a different view," he said, referring to his civilian post as secretary of defense.

McNamara also told the court that after former Johnson aide Walt W. Rostow testified in the trial, McNamara talked to him about their differences during the Johnson years when Rostow felt more optimism than McNamara about U.S. chances to win the war militarily.

"I saw Walt Rostow after he testified here, and we were commenting on this and we differed," McNamara said. Then, breaking into a smile, he added: "This was an open administration, that's why there wouldn't have been a conspiracy."

Leval quickly told the jury to disregard the comment, a clear reference to the contention in the CBS documentary at issue in the trial that Westmoreland participated in a conspiracy to keep higher enemy-troop estimates from the president.

McNamara also said the press knew at the time that he differed with Westmoreland and the joint chiefs about the war's progress.

Boies later told reporters that McNamara had provided few key statements for or against the network. He said McNamara's appearance on the stand allowed him to place into evidence, however, a May 1967 memo from McNamara to Johnson that supports the broadcast's version of a White House meeting a month earlier.