MOSCOW (AP) _ Saudi Arabia and the Soviet Union agreed Monday to restore diplomatic relations and exchange ambassadors after a break of more than 50 years, the official Tass news agency reported.

President Mikhail S. Gorbachev met the Saudi foreign minister, Prince Saud Al-Faisal Al Saud, and expressed the hope that bilateral relations between the Soviet Union and Saudi Arabia would help settle the Persian Gulf crisis, Tass reported.

''The restoration of diplomatic relations amid an acute crisis in the Arab East emphasized the resolve of both states to insistently seek the implementation of U.N. Security Council resolutions on the Persian Gulf in cooperation with other members of the international community,'' Tass said.

It said Gorbachev and Prince Saud ''assessed the possible conduct of the aggressor'' - meaning Iraq - in their Kremlin meeting. Prince Saud handed Gorbachev a message from King Fahd, the Saudi monarch, the news agency added, without disclosing its contents.

Earlier, the prince met with Soviet Foreign Minister Eduard Shevardnadze, and they urged the immediate withdrawal of Iraqi troops from Kuwait, Tass said.

In their discussions of the Persian Gulf crisis, Saud and Shevardnadze noted the similar positions of their nations and that both sides wanted a peaceful settlement.

''We hope that faced with the world community's unanimity, Iraq will agree to the immediate and unconditional withrdrawal of its troops from Kuwait and will restore legality,'' Tass quoted Prince Saud as saying.

Saudi Arabia and Moscow had full diplomatic relations until 1938, when dictator Josef Stalin closed his embassy in Saudi Arabia to save money. Several attempts to re-establish ties during the 1980s faltered over what Saudi Arabia called the Soviet Union's ''belligerent attitude'' toward its 50 million Moslems.

A Soviet-Saudi communique said the two nations decided to restore ties after indicating a ''desire to develop friendly relations,'' according to Tass.

''The sides agreed that their bilateral relations will be built in accordance with the U.N. Charter on the basis of principles of peaceful coexistence, equality and mutual respect for each other's sovereignty, territorial integrity and non-interference in internal affairs,'' the communique said.

Tass did not give a timetable when the two nations would exchange ambassadors, although it announced that the prince would hold a news conference Tuesday.

A full report on the prince's meetings with Gorbachev and Shevardnadze also was carried on the evening news program ''Vremya.''

Gorbachev asked Prince Saud to convey his best wishes to King Faud and the Saudi people, Tass said. The Soviet leader expressed hope that relations between the two nations would develop on a large scale, Tass said.

Soviet Foreign Ministry official Sergei Kirpichenko has been quoted as saying the establishment of official contacts between the Soviet Union and Saudi Arabia ''has long been ripe.''

On Sunday, Abdul-Wahab Abdul-Wasie, the Saudi Arabian Minister of Pilgrimage and Endowments, arrived in Moscow to attend a three-day Islamic conference and meet with Soviet Moslems, Tass said. The visit is the first ever to be made by a religious affairs minister to the Soviet Union.

Before leaving Saudi Arabia, Abdul-Wasie said he was seeking to consolidate cooperation between Soviet Moslems and religious circles in Saudi Arabia.

As part of the improving atmosphere between the two countries, King Fahd recently donated about 1.6 million copies of the Moslem holy book, the Koran, to Soviet Moslems. The Soviet Union allowed more than 1,000 Soviet Moslems to make the annual pilgrimage, or hajj, to Mecca this summer.