A U.S. District judge ruled yesterday that demonstrators can gather at entrances to the Pentagon as long as their protests are orderly and do not interfere with traffic around the building.

Judge Aubrey E. Robinson Jr. ruled in the case of two Christian pacifists who were arrested during an antinuclear demonstration in September 1978 after they had refused to obey an order to move from the Pentagon's main entrance within five minutes.

The two pacifists, Mary Birch of Arlington and Rosemary Maguire of Baltimore, were told they were in violation of a Federal Protective Service "policy" that prohibited more than two demonstrators at the Pentagon's Mall and River entrances at one time, Robinson said in an opinion. They were part of a group.

The arrests were based on a federal regulation that says that persons must comply with "the directions of federal protection officers and other authorized officials," Robinson said. That regulation is so broad and vague, Robinson said, that it gives those officers "unfettered discretion to exercise limitless police power."

Robin, who held that the regulation is unconstitutional, said that when there are no standards to govern arrests made on the basis of such a broad regulation, it invites arbitrary law enforcement against particular groups.

In the pacifist's case, Robinson said, the Federal Protection Service had relied on the regulation simply to "vindicate affronts to police authority."

Birch and Maguire are members of the Atlantic Life Community, a loosely knit group of antinuclear protesters who regularly demonstrate at the Pentagon.

Robinson specifically ruled that the Federal Protective Service and the Pentagon security force are barred from any further unreasonable interference with peaceful demonstrations at public areas near the Pentagon.

Robinson also held that Pentagon police officials were wrong when they arrested a third person, Norman A. Townsend, a Virginia lawyer who was at the Pentagon at the time representing the pacifist group. Townsend, who admitted that he threatened to sue the police when they attempted to disperse the protesters, was arrested for violation of a state law that prohibits curses and abuses directed at other persons.

Robinson said, however, that Townsend's arrest was unconstitutional because the particular statements he made were protected by the First Amendment rights of free speech.

The charges against Townsend, Maguire and Birch were eventually dismissed, Robinson said.He ruled, however, that the three have the right to sue the federal government for money damages as a result of the illegal arrests.

Robinson set a trial for damages in the case for April 14.