A federal judge told District police officers yesterday that they can no longer ask pedestrians to show identification and account for their presence unless the officer has cause to believe that the person was involved in -- or about to be involved in -- a crime.

The police department has a long-standing policy that has permitted thousands of such encounters, known in the department as informal "contacts," between police officers and citizens each year.

Senior Judge Edward M. Curran said yesterday that these "contacts" violate constitutional protections of personal privacy set out in the Fourth Amendment.

City lawyers argued that those safeguards do not apply to "contacts" because the citizens are free to walk away during such encounters. Lawyers for pedestrians who sued the police department argued that citizens are unaware that they do not have to cooperate, that police do not tell them, and the contacts are intimidating and often a form of harassment.

Curan's order was the latest episode in one of the oldest cases on file in U.S. District Court. Over the years, the case has focused on legally controversial and subtle debates about when police officers are justified in questioning citizens on the street.

The courts have long held that when a police officer "stops" a citizen and detains him or her for questioning, the officer must have reasonable grounds to believe that criminal activity has occurred or is about to occur. The city has contended that the incidents that Curran said were illegal were merely "contacts" with citizens that required no justification since the pedestrian was not required to cooperate with the officer.

Attorneys for the citizens argued that the mere presence of the police officer in uniform, with a badge and gun, was enough to make a pedestrian feel compelled to cooperate.

A survey of police department records showed that about 7,000 encounters occur each year in which officers approach pedestrians, question them and then make a record of the incident on an index card for police files, according to court records. A general order from the police department defining such "contacts" has been in effect since 1973.

The survey, conducted by lawyers and investigators representing citizens who sued the police department, listed various outcomes of such "contacts," inlcuding explanations that subjects were "just on the way to store" and "subject carrying a heavy green bag."

Such instances, attorneys for the citizens said, demonstrate that the police are routinely questioning citizens when there is "no reasonable belief of criminal activity."

The case before Curran was originally filed in 1967 by Manuel Gomez, a Washington tailor who had been stopped by police under the now-invalid vagrancy law. Since then the case has developed into a class action on behalf of all pedestrians in the District. Lawyers from the firm of Wald, Harkrader & Ross and the Washington chapter of the American Civil Liberties Union are now representing the pedestrians without charge. Other attorneys also are involved in the case.

"I think it's wonderful, I'm overjoyed," said Daniel Koffsky, an attorney at Wald, Harkrader. Arthur B. Spitzer, legal director of the ACLU office here, said Curran's order "recognizes that the police have to have a reason before they can interfere in a citizen's life."

While the city argues that pedestrians can walk away from such "contacts," Spitzer said that "in the real world, we all know that if that happens, you know you are going to stop . . ."

Assistant D.C. Corporation Counsel Michael E. Zielinski, who represented the police department in the lawsuit, said yesterday that the city plans to ask Curran to postpone the effect of his order until it can be taken to the U.S. Court of Appeals for review.

Curran issued a brief two-page order in the case yesterday.

Zielinski said that police officers often initiate "contacts" because they are curious about a subject's behavior, want to gather information or have a "sense that something is wrong."

"Some people might be offended by that, some people might feel they might want to stop and talk," Zielinski said in a telephone interview.

Many of the persons subjected to police "contacts" feel that the incidents were racially motivated, that "blacks don't belong in white neighborhoods," attorneys for the pedestrians said in court papers. Police records from 1974 to 1979 show that 46 percent of all police "contacts" occurred in the second police district, which principally covers the area of the District west of Connecticut Avenue. In his order, Curran told city lawyers that they have 15 days to draft a "brief, clear and lawful" order to be given to all police officers directing them to cease making illegal contacts with pedestrians. The proposed order, after negotiation with attorneys for the pedestrians, should then be submitted to the court for approval, Curran said.

Once the new order is approved, Curran said, the existing general order describing contacts "shall be rescinded."