Escaping a jail term Friday, former White House national security adviser Robert C. "Bud" McFarlane was placed on probation for two years and fined $20,000for deceiving Congress about the Reagan administration's secret plan to assist the Nicaraguan rebels.

McFarlane, the highest-ranking Reagan administration official to be convicted in the Iran-Contra scandal, pleaded guilty a year ago to four misdemeanor charges and faced a possible maximum penalty of four years in prison and a $400,000 fine.The plea was part of a deal in which independent prosecutor Lawrence E. Walsh extracted McFarlane's cooperation and his promise to provide key testimony against Iran-Contra defendants.

Most prominent among them is ex-Marine officer Oliver North, who worked for McFarlane at the National Security Council and is on trial on charges of covering up a secret, allegedly illegal program to assist the Nicaraguan rebels.

In addition to probation and a fine, McFarlane was ordered by Chief U.S. District Judge Aubrey E. Robinson Jr. to perform 200 hours of community service, which was unspecified.

The judge said he had received letters, some unsolicited, on McFarlane's behalf. But his clerk would not say whether any came from former President Reagan, President Bush or other top officialsi.

Grim-faced, his hands clasped in front of him, McFarlane told the judge in aquavering voice: "Clearly this (Iran-Contra) episode in our history has resulted in enormous turmoil in our country's processes. To the extent that I contributed to that, I regret it."

McFarlane, his voice trailing off and barely audible, added: "I tried to serve my country and I will continue to . . ."

Later, outside the courthouse, he said that "the machinery through which the presidency and Congress forged foreign policy didn't work very well" in the Iran-Contra affair and remains a serious national problem.

"But as for me, a strong faith and a terrific wife and a free country, I'm looking to the future," he said.

Walsh said he had made "no recommendation whatsover" to the judge about McFarlane's sentence. He refused to say whether he thought the sentence was appropriate. Asked why, he replied, "There are other cases."

In an opening statement in the North case, trial prosecutor John Keker said McFarlane is "still reluctant to take responsibility for what happened. . . . He's going to blame Oliver North for lying to him."

McFarlane's testimony is expected to challenge the core of North's defense - that he was authorized by higher officials to help the Contras and to conceal his activities, even from Congress.

Sources said McFarlane asked to be sentenced before becoming a witness against North, in hopes of dispelling suspicions that he would slant his testimony in expectation of leniency.

In a related development, federal judge Gerhard Gesell, who is presiding at the North trial, said at a Friday hearing that the government violated the law in classifying "masses of documents" involved in the trial.

He said, for example, that he knew of no legal basis for classifying the grand jury testimony of McFarlane and other government witnesses.

"Whole documents are stamped `Top Secret' before they're read and some sensitive documents are not stamped at all," the judge complained.