Tens of thousands of people packed the central square of Baku, Azerbaijan, on Friday, facing Red Army tanks sent by the Kremlin to quell ethnic rioting and panic in the southern republics of Azerbaijan and Armenia.

A spokesman for the Azerbaijan government said by telephone from Baku that soldiers had cordoned off Armenian districts in the city of 1.7 million people.Mikhail S. Gorbachev, president and Communist Party chief, said Soviet leaders would meet soon with delegations of Armenians and Azerbai-janis seeking a "solution that would conform to the best interests of these two peoples and our country."

Gorbachev made the comment in a joint interview with visiting President Francois Mitterrand of France broadcast Friday night on the French television network Antenne-2. (See story below.)

Scenes of milling masses and military armor in both Baku, a city in Azerbaijan, and Yerevan, capital of neighboring Armenia, were shown on the Soviet evening television news.

An announcer said, "The passions and emotions accumulated in the hearts of Baku residents spill out in the square," and another in Yerevan added: "Contradictory rumors are being floated that aggravate the atmosphere."

More than 2,000 ethnic Armenians have fled Azerbaijan to Armenia, panicked by violence that killed three people and injured at least 126. Reports of far higher tolls are rife in the Armenian community but cannot be confirmed.

Ethnic conflict in the two Caucasus republics began last February because of a dispute over Nagorno-Karabakh, a territory with a predominantly Armenian population that has been part of Azerbaijan since 1923.

Armenians held general strikes and mass demonstrations demanding that the territory be annexed to Armenia, although they do not have a common border, but Moscow did not approve it.

A riot Feb. 28 in the Azerbaijani city of Sumgait killed 32 people, 26 of them Armenians.

Armenian legislators issued another challenge to Gorbachev's policies Friday, at an impromptu meeting that rejected his proposed constitutional reform and again demanded annexation of Nagorno-Karabakh.

Musa Mamedov, chief of information for the Azerbaijan Foreign Ministry, said Baku remained tense and industries in the Caspian Sea port were closed by strikes. Soviet television confirmed the strikes.

He said Interior Ministry soldiers had cordoned off Armenian districts. In a report Thursday, Mamedov said people were killed in Kirovabad, but on Friday he called that "unofficial information" and said he had nothing official about Thursday's events in Kirovabad.

Izvestia, the Soviet government newspaper, said pressmen in Baku refused to print local copies of national papers Friday "because they are reporting nothing about events in Azerbaijan." Izvestia said it had to ship 134,000 copies from Moscow.

Gennady I. Gerasimov, the Soviet Foreign Ministry spokesman, said in Moscow that tanks and troops had been sent to re-establish order in Baku and in Kirovabad and Nakhichevan, the cities where rioting began Tuesday.