MOSCOW (AP) _ Mikhail S. Gorbachev and Iranian Parliament Speaker Hashemi Rafsanjani discussed prospects for settling conflicts in the Middle East and Afghanistan in the first of two meetings between the leaders, Tass said.

The Soviet president on Tuesday warmly greeted Rafsanjani, the highest Iranian official to visit Moscow since the 1979 Iranian revolution, and met with him again today.

The official Soviet news agency said Iranian Foreign Minister Ali Akbar Velayati was meeting with Eduard A. Shevardnadze, the Soviet foreign minister.

Asked about possible arms sales to Iran, military chief of staff Gen. Mikhail A. Moiseyev told a news conference that Gorbachev and Rafsanjani would be meeting and said any decision would be made by ''the political leadership.''

On Tuesday, Gorbachev warmly greeted Rafsanjani to Moscow and promised that the Kremlin will not damage Tehran's interests. Rafsanjani said Gorbachev's reforms and Iran's strength will help improve relations, Tass said.

The Soviet leader said although relations between the neighboring countries have not always fared well, ''there cannot be and will not be anything in our policy now that would damage Iran's interests.''

The leaders discussed prospects for settling conflicts in the Middle East and Afghanistan, and their attitudes toward other countries, Tass said.

Rafsanjani, who before leaving Tehran recalled that Russian empires always had coveted Iran, was reported to have listed areas of agreement between the two nations. They included universal disarmament, the question of foreign military in the Indian Ocean, a neutral Afghanistan and national self- determination as areas where the two could come very close.

Rafsanjani expressed hope before he left home that the visit will open ''a new chapter in Iranian-Soviet relations and in the history of the region,'' the official Islamic Republic News Agency said.

Tass said earlier: ''In the Soviet Union there is confidence that the visit by Rafsanjani will give fresh impetus to the continued progress of Soviet- Iranian relations ... and will help improve mutual understanding and strengthen cooperation between the two countries.''

His delegation included Velayati and Mohsen Rezaie, commander of Iran's Revolutionary Guards.

Rafsanjani also is acting commander-in-chief of Iran's armed forces.

Economics Minister Mohammad Javad Iravani preceded Rafsanjani to Moscow to prepare economic and commercial agreements, the Iranian agency reported.

Iran officially has a non-aligned foreign policy, but Rafsanjani said earlier this month that the Ayatollah Ruhollah Khomeini had instructed him to improve relations with Moscow. Khomeini died on June 3.

With ties to the West strained, Tehran is looking to the Soviet bloc for help in rebuilding Iran after its eight-year war with Iraq.

Relations between Tehran and Moscow soured soon after the 1979 Iranian revolution. That December, Soviet troops deployed to help the Afghan government fight Moslem fundamentalist guerrillas, and Iran in 1981 repressed the Tudeh Communist Party.

The Soviet Union was one of Iraq's major arms suppliers in the Iran-Iraq war, which ended with an August 1988 cease-fire.

Soviet-Iran relations improved when Soviet troops withdrew from Afghanistan on Feb. 15.