Greek Prime Minister Andreas Papandreou ended his four-day visit to the Soviet Union today with the publication of a joint communique that repeated his appeal to bar the militarization of space, Moscow's key priority going into next month's arms talks in Geneva.

Papandreou, whose Socialist government has broken with fellow NATO members on missile deployments and other issues, appeared to tread softly on East-West issues during the visit, and diplomatic observers characterized the communique as moderate in tone.

For their part, the Soviets took care not to join Greece in a condemnation of Turkey, Greece's historic rival and now its partner in NATO.

In the only reference to the Greek-Turkish disputes over the Aegean Sea, the joint communique tonight said questions about territorial rights in the Aegean "should be settled by peaceful means in accordance with the standards of international law." Turkey was not mentioned.

According to western diplomats, the Greeks had pressed for stronger language, but the Soviets followed a traditional practice of trying to keep out of bilateral disputes.

The joint communique welcomed the coming U.S.-Soviet talks in Geneva and avoided any critical references to the United States.

Papandreou's warming relations with Moscow and his independence within NATO have been an irritant to Washington.

Papandreou did not have a chance to meet with Soviet President Konstantin Chernenko, reported to be ill again, but meetings with Premier Nikolai Tikhonov and Foreign Minister Andrei Gromyko were described as "businesslike and friendly."

The main results of Papandreou's visit here were in the economic field. Agreements were signed to extend contracts on ship repair, transport, and social security settlements for Greek Communists returning home from exile in the Soviet Union.