Chinese leader Hua Kuo-feng wound up a tour of Romania. Yugoslavia and Iran yesterday after a stop in Tehran that was overshadowed by domestic turmoil.

Iranian sources indicated that the three-day visit, the first by a Chinese Communist head of state to a noncommunist country, was deliberately played down by Hua's hosts to avoid offending the Soviet Union. Iran's neighbor to the north.

Both they and a Chinese source acknowledged, however, that security in Iran - racked by eight months of anti-government violence - was also a factor in keeping Hua's profile low. There were signs, too, that the communist leader may have felt some discomfort with the imperial trappings of the shah's court.

Unlike Hua's two previous stops on his two-week tour, there were no cheering crowds, no visits to factories and no public appearances with the host leader. In fact, there was so little advance publicity that many Iranians seemed unaware or unconcerned that the chairman was in town.

An Iranian security man guarding Hua Kuo-feng's ornate Golestan Palace guest residence asked a reporter in all seriousness if he had come to Tehran especially for the visit of "Mr. Hung Fu."

Along with the lack of public fanfare was a dearth of official information. No press conference or briefings were given by either side, and no final communique was issued.

A Chinese informant said, however, that Chairman Hua and Shah Mohammed Reza Pahlavi had got on well together and had been in agreement on several vital issues. He said both men viewed with alarm the pro-Moscow coup in Afghanistan in April and the takeover in South Yemen by Soviet-oriented hardliners shortly afterward. China and Iran reportedly see both moves as evidence of "expansionist" Soviet aims in the area.

The two men are also said to have expressed concern about Pakistan, which China supports even though it is allied with Iran, Turkey, Britain and the United States in the anicommunist Central Treaty Organization. Both Hua and the shah are worried that following the coup in Kabul. Pakistan could fall victim to Soviet-backed tribal secessionist movements that could dismember the country and provide the Soviet Union with its long-sought warm-water port on the Italian Ocean.

Iranian officials said the fact that the two men talked for 40 minutes more than the scheduled hour Thursday was a sign that they had a lot to discuss. On Wednesday they had met for an hour and a half, 30 minutes in private and an hour with aides in attendance.

On a lower echelon, Iranian and Chinese officials did not appear to have understood one another as well.

Although the two foreign ministers signed a cultural accord, there apparently were some snags in negotiations a scientific and technical agreement that would, among other things, provide Iranian experties in helping Cihna develop its oil resources.

But the overriding concern of Hua's entourage seemed to be his security. The visit came only two days after the shah was forced to appoint a new government in an effort to appease religious and political opposition to his rule. Security around Hua's Golestan Palace guest residence in teeming South Tehran, a short distance from the turbulent Bazaar area, was drumtight to prevent the approach of any demonstrators.

Local residents, meanwhile, were more concerned about domestic political issues. When a mob of several thousand attacked a bank branch Wednesday night about a mile and a half away from the palace. It was enough to alarm the Chinese. Hua's trips the next day to see the imperial Museum were canceled on the advice of Chinese security men, according to an official in Hua's delegation.

Hua's plan to drive to his meeting with the shah in north Tehran in a motorcade was also abandoned, as was a scheduled limousine ride with the shah from the airport to Golestan Palace. Instead, both men traveled by helicopter.

There also were indications that the Chinese leader might have been a bit bothered by the royal luxury and the undemocratic atmosphere in which he found himself.

At a lavish state banquet on the first night of his stop, Hua joined the shah and Express Farah in greeting guests in an ornate mirrored room under massive glittering chandliers.

Hua stood stoically in a dark Mao suit as heavily decorated Iranian generals clicked their heels and stood at attention in front of the shah, then bowed low and kissed his hand.

Indeed, some diplomats with experience in Chinese affairs expressed surprise that Hua had scheduled visits to see the crown jewels and the royal museum in the first place. Although in the end the chairman did not go, members of his delegation headed by Vice Premier Chi Teng-kuei did make those stops, an idication of the importance the Chinese attach to good relations with Iran.

As the chairman prepared to leave this country of 35 million people, this story was going around in Tehran:

The shah asks Chairman Hua, "In your country, how many people are against you?" Hua reflects and ansers, "about 35 million." The shah reflects and says, "It's about the same here."