Iranian Army troops intervened tonight to stop a two-hour firefight in the northwestern city of Tabriz between Ayatollah Ruhollah Khomeini's followers and Azerbaijanis demanding autonomy for Iran's largest province.

Supporters of Ayatollah Kazam Shariatmadari, effective leader of the rebelious province, said in the holy city of Qom that the troops were loyal to him and not to Khomeini and had stepped in at Shariatmadari's request to end the fighting.

Reports from Tabriz said that at least five persons were killed in today's battle and at least another 26 were wounded. The fighting made the day by far the most violent since followers of Shariatmadari seized portions of the city last Thursday and underscored the growing differences between the central government and the inhabitants of Azerbaijan Province, who make up a third of Iran's population.

Hours after the firefight, it was unclear whether Khomeini forces or Shariatmadari loyalists had the upper hand in Tabriz, where fighting raged at the government's radio and television station. Telephone callers to the station were told that it was in the hands of Khomeini supporters and that the troops had intervened on Khomeini's behalf.

In Qom, Shariatmadari's followers said they had received pledges of support from military garrisons throughout the province that either had sent or were offering to send reinforcements to Tabriz.

Shariatmadari has claimed that all Tabriz Army, Air Force, police gendarmerie and Revolutionary Guard units were loyal to his cause.

Today's clashes began with a rush on the radio and television station by followers of Khomeini, who routed armed supporters of Shariatmadari, who in turn fled without firing when a large crowd broke down the fences surrounding the transmitters and fired into the air.

Later in the afternoon, Shariatmadari's loyalists regrouped and mounted a fresh attack on the station but were met by heavy firing from Khomeini's forces. Eyewitnesses near the station said they saw ambulances racing between the scene of the fighting and hospitals in the city of 500,000.

The troubles in Azerbaijan flared into violence last week because of a Wednesday night attack on Shariatmadari's compound in Qom in which pro-Khomeini demonstrators shot and killed one guard and one soldier and wounded some 15 other followers. The demonstrators were protesting Shariatmadari's call to boycott the constitutional referendum earlier in the week that conferred virtually unlimited powers on Khomeini as the country's supreme ruler.

While Shariatmadari clearly enjoys widespread support in Azerbaijan, his followers are not well organized and he does not have a military force.

Officials of Shariatmadari's Moslem People's Republican Party admitted as much in confirming that 500 leftist Kurdish guerrilas loyal to Sheik Ezzedine Hosseini were fighting side-by-side with the Shariatmadari loyalists.

The Kurds, who are approaching the end of a 20-day cease-fire in which they claim the central government has failed to negotiate their autonomy claims, yesterday announced their support for neighboring Azerbaijan's demands for similiar treatment.

Early in the afternoon, Khomeini broadcast a radio message blaming the trouble in Tabriz on "traitors," "stooges," and "plotters who receive their orders from America and other places."

That was before his loyalists recaptured the radio-television station, the provincial governor's office and other government buildings. Shariatmadari loyalists eentually retook all but the radio station and were pouring automatic weapons fire into the hillside complex when the Army intervened at 10 p.m. local time.

The soldiers occupied the station, threw out the pro-Khomeini forces, and kept a large number of Shariatmadari sympathizers at bay, according to party officials.

At the start of the fighting, pro-Khomeini defenders announced over loudspeakers that they had with them women and children who apparently took part in the capture of the station early in the afternoon, the party officials said.

As soon as the pro-Khomeini takeover of the radio-television station became known just before dark, tens of thousands of infuriated Shariatmadari sympathizers rushed to the neighborhood, according to reports from tabriz.

"Death to Khomeini," "Allahu Akbar" (God is Great) and Shariatmadari is our leader," they shouted as they armed themselves, in many cases with branches from trees.

The day began in defiance of Shariatmadari's call for no demonstrations when 4,000 Khomeini supporters gathered at the bazaar in central Tabriz this morning and marched to the university to hold a unity prayer session there.

The crowd grew to some 10,000 and marched a quarter mile farther to the radio-television complex, where a small group rushed the guards at the gate and disarmed some 40 to 50 Moslem People's Republican Party guards.

The Khomeini demonstrators went on the rooftops, and put the flag, which had been at half staff since the takeover Thursday, back on the top of the pole. Then the Khomeini forces took the station back.

The first inkling of trouble surfaced when Radio Tabriz went off the air, apparently because the sabotage by pro-Khomeini forces. The damage was repaired rapidly.

During the early afternoon, the national radio broadcast a series of appeals from various pro-Khomeini ayatollahs, demanding that Shariatmadari dissolve his party, which they said was "influenced by the opponents of Islam and reactionaries," and evacuate the Tabriz government buildings.

In the evening, Khomeini's aides were quoted by the state radio as reiterating the request to dissolve the party "to prevent any further splits in Islamic ranks."

The Ministry of National Guidance, in a move aimed at Shariatmadari's party, banned distribution of pamphlets or newspapers published in Azerbaijan without official approval.

Meanwhile, the Revolutionary Council announced tonight that Finance and Economy Minister Abol Hassan Bani-Sadr would lead a three-man government delegation to deal with the Azerbaijan crisis.

He replaces former prime minister Mehdi Bazargan, a native of Azerbaijan, who angered residents of Tabriz by charging that communists and other leftists were behind the pro-Shariatmadari takeover of government buildings on Thursday.