Western powers, China and Iran yesterday marked the third anniversary of the Soviet invasion of Afghanistan by calling on Moscow to end its occupation of the Asian country.

In Washington, President Reagan reaffirmed U.S. support for a negotiated settlement that would return Afghanistan "to the ranks of independent, nonaligned nations."

"We in the United States," he said, "sincerely hope that the new leadership of the Soviet Union will take advantage of the opportunities the new year will no doubt offer to achieve a solution for Afghanistan.

"The American people do not want to see the suffering and deprivation of the Afghan people continue," Reagan said in a written statement. "But we will not grow weary or abandon them and their cause of freedom."

The West German and Italian foreign ministries also condemned the Soviet intervention in Afghanistan and urged withdrawal.

In Bonn, Foreign Minister Hans-Dietrich Genscher said in a statement that more than 3 million Afghans, about one-fifth of the population, have fled the country while military resistance to the Soviet occupation forces continues.

In Peking, the Communist Party newspaper said that the Soviet invasion marked "a major step in the Soviet global strategy for world domination." An editorial in People's Daily said that Moscow intended Afghanistan to become "a springboard for its southward drive.

"By invading Afghanistan and massing its troops along the Afghan-Chinese border, the Soviet Union is also posing a grave threat to China's security," the paper said.

In Iran, which borders both the Soviet Union and Afghanistan, Tehran radio broadcast a Foreign Ministry statement calling "for the immediate and unconditional withdrawal of the Soviet forces from Afghanistan , the return of millions of Afghan refugees to their home country, and the right of the Moslem people of Afghanistan to determine their own destiny."

The Soviet Union invaded the mountainous, landlocked country on December 24, 1979 and three days later installed Babrak Karmal as president.

The invasion began with the airlift of an airborne division from Moscow that landed in the capital of Kabul. Simultaneously, a ground invasion by two motorized rifle divisions started from the Soviet-Afghan border.

The Soviets now have about 105,000 troops in the country.