Marine Staff Sgt. Robert Stufflebeam was demoted one rank to sergeant yesterday for dereliction of duty in having had drinks at off-limits Moscow bars.

His demotion, by a jury of three officers and five enlisted personnel that had convicted him of the two least serious of nine charges after two days of testimony Thursday, will cost him $113.60 a month in basic pay. He will spend no additional time in confinement.

Stufflebeam could have been sentenced to a year in prison for conviction of the two charges. Had he been found guilty of all nine charges, the sentence could have been 14 1/2 years.

Describing the Naval Investigative Service (NIS) probe that led to his arrest on the nine charges of dereliction to duty as a "witch hunt, a joke," Stufflebeam said outside court at the Quantico Marine Corps Base that he has no future in the Marines and probably will leave the Corps when his enlistment expires in 1989.

Stufflebeam, 25, of Bloomington, Ill., second in command at the Marine Security Guard detachment at the U.S. Embassy in Moscow in 1985, also criticized "the few Marines who decided that if one Marine is dirty, all are dirty."

The NIS investigation was launched in the wake of disclosures by Marine Sgt. Clayton Lonetree, Stufflebeam's one-time subordinate in Moscow, that he had contacted Soviet secret police, or KGB, agents. Last month, Lonetree was sentenced to 30 years in jail for espionage.

"The sentence has restored my faith in due process, but the investigation speaks for itself," Stufflebeam said of his demotion. He had testified earlier yesterday that the Marines had denied him legal counsel for several days during the inquiry after he asked to see a lawyer.

Stufflebeam said he sought a lawyer while he was being interrogated at Camp Pendleton, Calif., but the Marine Corps did not assign one until he reached Quantico so that it would not have to relocate West Coast Marines, Corps officials testified.

In a sworn statement admitted during the three-day court-martial, Stufflebeam conceded that he had sex with two Soviet women three times and that he lied about it. He was, however, acquitted on seven misconduct charges related to these incidents.

Government prosecutor Maj. Lawrence W. Koenig had asked the jury to impose a three-month jail term although he could have sought a year's imprisonment. Defense attorney Navy Lt. Gregg Nozum asked for an unspecified demotion or no punishment.

Marine Lt. Col. Eligah Clark, the presiding judge, had ruled earlier that, for purposes of sentencing, Stufflebeam had already served 54 days in pretrial confinement. Stufflebeam actually was confined for 41 days, but Clark counted some of them two or three times because of various infringements of the military code by NIS agents and Marine authorities.

In earlier testimony NIS special agent James Pender said Stufflebeam had been free to leave the Oceanside, Calif., hotel where he was interrogated for three days in March.

Stufflebeam testified yesterday, however, that he had requested leave several times but had been told he was in "protective custody." He believed he was not allowed to leave, he said.

Before the jury entered the courtroom to hear evidence for sentencing, Stufflebeam testified that he had been told during later confinement that he was being restricted and guarded because "if there was not a restriction, I would meet with a KGB agent." He was not originally told that he was suspected of fraternization with Soviet citizens, he said.

Defense counsel Marine Capt. Angela F. Epps pointed out that in terms of military law, suspects must be granted military counsel. But two lawyers who visited Stufflebeam in the Camp Pendleton brig were turned away, she said.

Stufflebeam said outside court that the names of the lawyers had been erased from a brig log book to make it appear they had never been there.

Marine Lt. Col. Jim Schwank of the Corp's legal department testified that Stufflebeam had been denied legal counsel while he was held in Camp Pendelton because Marine authorities knew Stufflebeam was due to be sent to Quantico and waited until he arrived at Quantico to assign counsel so as not to have to relocate West Coast Marines.