A shouting crowd of 300 Afghans, carrying brightly colored banners and chanting slogans in English and their native language, marched through a light rain yesterday near the Soviet Embassy to commemorate the second anniversary of the Soviet invasion of their homeland.

Alternately shouting "Allahu Akhbar" (God is great) and "Long Live Freedom," the Afghan demonstrators gathered at noon in Farragut Square and then marched up K Street NW, where about 20 of them clashed briefly with D. C. police dressed in anti-riot gear.

After more than an hour of fiery speeches and chants, several dozen demonstrators, most of them apparently in their teens and early 20s, charged a line of helmeted, club-wielding police at 16th and K streets NW. Police pushed the demonstrators back, but arrested only one person, an Afghan youth who was charged with disorderly conduct.

Police, with tear gas readied, said they were enforcing the city law preventing demonstrators from getting closer than 500 feet to an embassy--in this case, the Soviet Embassy on 16th Street between L and M streets. About 30 police, with a dozen vehicles, had closed off 16th Street near the embassy.

Omar Mojaddidi, a march organizer who said that 84 members of his family have been imprisoned by the Soviet-backed regime in Kabul, said yesterday's protest was the largest of about 20 staged by the roughly 2,000-member local Afghan community since Dec. 27, 1979, the date the Soviets invaded Afghanistan.

"We are just trying to show people of the world our hatred for the Russian invader," said Mojaddidi, a 33-year-old economist who now lives in Springfield and drives a cab in the District. Mojaddidi said the Communist regime imprisoned his family, including two brothers and two uncles, because they were religious and political leaders opposed to Soviet intervention.

Mojaddidi said he, like other Afghans, had come to America on what he thought was to be a temporary visit. In 1978, he said, he was visiting his brother here and considering graduate school in the United States, but the Soviet-backed coup that then toppled the existing govern-ment forced him to stay here. He compared his plight to that of many Polish people in the United States today.

"The American administration is not doing anything in Poland, or in Afghanistan," he said, "If they don't stop the Soviet Union in Afghanistan and Poland, they will have to face them in Western Europe . . . and eventually in Washington, D.C." While the Reagan administration is supplying aid to the Afghan rebels, Mojaddidi said the protesters believe it is not nearly enough.

Yesterday's crowd, many with family remaining in Soviet-occupied Afghanistan, shouted Islamic prayers alternated with English slogans such as "Live for Freedom, Die for Freedom, Kill for Freedom." Mojaddidi and several others led the chanting with megaphones from atop a pickup truck parked in the intersection of 16th and K streets.

Following the 2 p.m. arrest of the youth, later identified as a juvenile, about half the crowd sat down in the intersection, saying they would not move until the young demonstrator was freed. An hour later the demonstration broke up. The juvenile was later freed but must return for a court appearance.

A block away, the Soviet Embassy was locked, with a sign that said "Closed Today."

In a separate demonstration, about 50 opponents of the Ayatollah Ruhollah Khomeini regime in Iran were barred by police from the site of the Iranian Embassy at 3005 Massachusetts Ave. NW, where they had planned to raise the flag of the late shah.

D.C. police said that although Iran was evicted from the site when the United States broke diplomatic relations, the property still technically is a foreign embassy, so the 500-foot rule was invoked. Police said the protesters marched near the embassy and fought briefly with several carloads of pro-Khomeini Iranians. Rocks were thrown but no injuries were reported.