Iran will view the United States and the Soviet Union with an equally critical eye as long as Soviet troops remain in Afghanistan and Moscow refuses to denouce Iraq for its role in the Persian Gulf war, the official Iranian news agency reported today.

The policy declaration, which the agency said came in a meeting last night between Prime Minister Mohammed Ali Rajai and Soviet Ambassador Vladimir Vinogradov, constituted Iran's sharpest public criticism of the Soviet Union since the Islamic revolution here two years ago.

According to the agency, Pars, Rajai told Vinogradov that the Soviet Union is inconsistent in attaching U.S. policies around the world while remaining silent about its own presence in Afghanistan and "flagrant Iraqi aggression against Iran" in the Persian Gulf conflict. Why does Moscow ignore the problem of Afghanistan while declining to force the Iraqis to withdraw from Iranian territory, he asked.

"As long as there is not a suitable answer to these questions, the Moslem and revoluntionary people of Iran will not make any distinction between the actions of the two superpowers," Rajai was quoted as saying in the 45-minute meeting. "As far as we are concerned, there is no difference between aggressors, and condemnation should not be limited to a specific country."

On the domestic front, former prime minister Mehdi Bazargan sharply criticized President Abol Hassan Bani-Sadr, Rajai and the Supreme Court chief, Ayatollah Mohammed Beheshti, saying a dangerous feud has grown out of their struggle for power.

Bazargan, now a parliamentary deputy for Tehran, said Bani-Sadr pays "too much attention to his post" and Rajai "uses his efforts to block the way for the president." He accused Beheshti of misusing his post to spread propaganda and of exceeding his jurisdiction.

Bazargan, head of a provisional lay government after the revolution that toppled the shah two years ago, singled out Beheshti for especially sharp criticism in a parliament speech and spoke of "the dangerous deadlock that stubbornness or the struggle for power has created."

Bazargan said Beheshti, who is also a founding leader of the dominant radical Islamic Republican Party, "makes propaganda by taking an outstanding and exceptional advantage of the mass media . . ."

"Contrary to the principle of separation of the three branches of state, little of the affairs of the country is not under his influence, officially or unofficially," Bazargan said.

Bazargan, a veteran moderate politician who supports Bani-Sadr, did, however, charge the president with taking "action far more direct and free than constitutional law allows him, and [he] probably interferes over the head of the prime minister and the Cabinet."

He said Rajai, "who has introducted himself as the little brother of the president, most of the time does not fulfill the conditions required of brothers, shows more . . . compliance toward the dominant group and uses his efforts to block the way for the president."

In other demonstrations of political rivalry reported by Iranian newspapers, several civilians and Islamic Revolutionary Guards were wounded yesterday in clashes between rival factions in two Iranian towns in the Caspian Sea region.

The newspaper Islamic Revolution, quoting its correspondent in Kutchesfahan, 12 miles east of the provincial capital of Rasht on the Caspian coast, said "a number of stick-wielders and holligans" armed with pistols, automatic rifles and knives attacked a mosque in the town, where people had gathered to hear a speech by a member of the Majlis, or parliament.

The newspaper said the incident occurred when Hojatoleslam Hassam Lahuti, a Majlis deputy for Rasht and a supporter of Bani-Sadr, was addressing several thousand people.