QUANTICO, VA., AUG. 12 -- -- Marine Sgt. Clayton J. Lonetree was one mistake away from being kicked out of the U.S. Embassy in Moscow in 1985 when he made a dramatic turnaround and was granted an extended tour of duty, his commander testified today.

Master Gunnery Sgt. Joey Wingate said Lonetree, who spent 17 months at the embassy, had been caught sleeping on the job once and out of uniform at another time and had problems adjusting socially to life in the Moscow diplomatic complex.

Lonetree, 25, is being court-martialed at the Quantico Marine base, accused of giving KGB agents U.S. secrets in exchange for sex with a Soviet woman. He is the first Marine tried on espionage charges.

Wingate testified that Lonetree, faced with threats that he would be relieved of duty, changed his attitude and impressed his superiors.

"I looked at him as a Marine who had failed in his duties, paid his dues and now he was starting on the right foot," Wingate said.

When Lonetree eventually requested a 90-day extension on his tour, it was granted.

In other testimony, defense attorneys said that Lonetree may have been a pawn in a government ploy to shield a double agent.

Prosecutors have alleged that Lonetree handed secrets, including the identities of CIA agents, to the KGB through a man identified as Sasha. Lonetree was introduced to Sasha by a Soviet girlfriend, Violetta, alleged to have seduced Lonetree into spying.

But defense attorney Michael V. Stuhff said the State Department has stayed in contact with Sasha for some time.

The defense has been granted permission to interview Shaun Byrnes, a department official in Moscow said to have had contacts with Sasha.

"The role of Sasha and his true relationship to this situation are extremely crucial," Stuhff said in court today in seeking permission to interview two other State Department officials said to have maintained contacts with Sasha.

"It may very well be that Sasha was an asset of Shaun Byrnes'," Stuhff said. That raises the possibility that Lonetree was set up "so he would give credibility to Sasha in his role as a double agent," the attorney said.

Later in the day, the defense learned it can examine intelligence cables that should provide more information on the State Department's relationship with Sasha.