BELGRADE, Yugoslavia (AP) _ The ruling parties of Serbia and Montenegro agreed Tuesday to work to keep Yugoslavia intact and prevent another civil war in the Balkans.

Aside from saying they would continue the talks, however, rival Montenegrin and Serbian officials apparently failed to agree on how the troubled Yugoslav federation should be restructured.

Montenegro, Serbia's smaller partner in Yugoslavia, wants more independence from President Slobodan Milosevic's regime, which is under international sanctions.

The former Yugoslavia, which once consisted of six republics, broke up in a series of civil wars beginning in 1991 after Milosevic tried to quash pro-independence movements.

Montenegro's ruling Democratic Party of Socialists has said it will organize an independence referendum if talks to restructure Yugoslavia fail. Milosevic's neo-communist and ultra-nationalist coalition partners have warned of a new war if Montenegro tries to secede.

Top officials from Milosevic's Socialist Party met a Montenegrin delegation in Belgrade on Tuesday. Later, the Montenegrins met the neo-communist Yugoslav Left party led by Milosevic's wife, Mirjana Markovic.

After the talks, both sides expressed some optimism, but offered no solutions.

``Yugoslavia is in the interest of both the Serbian and Montenegrin people,'' said Gorica Gajevic, the general secretary of Milosevic's party.

Svetozar Marovic, who led the Montenegrin delegation, said the two ruling parties agreed ``that despite the political differences, we have two things in common: We want to save the country we live in and we want to preserve the equality for both Serbia and Montenegro.''

He later conceded that there were stark differences in their vision for Yugoslavia, with Montenegro favoring a more democratic course.

``We do not propose a partition but a more democratic and more prosperous Yugoslavia,'' Marovic said.

Marovic's latest remarks suggested a possible softening of Montenegro's demands for immediate independence.

The United States and other Western governments have appealed to Montenegro for restraint, fearing another bloody showdown in the Balkans.

Montenegro's president, Milo Djukanovic, recently said that Yugoslavia no longer exists because his republic already pursues independent economic and foreign policies. The Yugoslav army stationed in Montenegro remains one of the few institutions still under Belgrade's control.

Ivan Markovic, the spokesman for the neo-communists, said that there were ``unpleasant details'' during the talks.

``We did not use only diplomatic language,'' he said.