A decision Friday by D.C. police officials to remove Detective James L. Stays from Mayor Marion Barry's security detail was prompted by a suggestion more than a week ago at the mayor's drug trial that Stays had used cocaine, a police source said yesterday.

Stays, a member of the police force for almost 30 years and a member of the mayor's security unit for 11, was removed Friday pending an internal police investigation, according to other sources.

A police source said yesterday that Stays's removal was set in motion July 19, when Assistant U.S. Attorney Judith E. Retchin told U.S. District Judge Thomas Penfield Jackson in a bench conference that the government had evidence of cocaine use by Stays.

After Retchin's assertion, the police Internal Affairs Division contacted the U.S. Attorney's Office, the source said. Members of the internal affairs unit were told, according to the source, that a witness had testified before a grand jury that she saw Stays use cocaine at a cookout in Kettering in August 1985. The grand jury testimony was reviewed by police, the source said.

A source has said that Retchin's bench conference statement was a result of earlier inquiries by the internal affairs unit into allegations of improprieties by some members of the mayor's security detail.

But it was not until Retchin made her bench conference suggestion, according to the source interviewed yesterday, that police officials learned prosecutors had a witness, Delois Ann Mise, who would testify that she had seen Stays using drugs.

Sources said Stays was stripped of his police powers and was assigned to an administrative post.

When he testified two weeks ago, Stays denied that he had used drugs, and associates said Stays has told them he has been wrongly accused. He declined to comment on the matter Friday night.

Barry yesterday declined to comment directly on Stays's suspension.

He suggested that the action was another example of how "the federal government plays dirty."

Staff writer Michael York contributed to this report.