Dobrica Cosic, a novelist and outspoken Serbian nationalist who served briefly as president of Yugoslavia in the early 1990s when its breakup in the midst of sectarian war was already underway, died on May 18 in Belgrade, the Serbian capital. He was 92.

His family confirmed his death to news outlets in Belgrade.

Mr. Cosic was a novelist before he was a politician, and a Communist before he was a nationalist. Aligned early in his career with Josip Broz Tito, the president of Yugoslavia when it was formed from six distinct regions after World War II, he spoke of Communism’s capacity to knit together the country’s diverse ethnic and cultural groups.

But by the 1960s Mr. Cosic (whose full name is pronounced DOE-bree-tsah CHO-sitch) began questioning how the government and other groups in the region were treating Serbs, the largest ethnic group in the republic but one that, unlike others, had no stand-alone state.

“A Time of Death,” his epic series of novels about how the tragedies Serbia suffered during World War I ultimately made the Serbian people stronger, was among several of his novels and other writings that have been credited with inspiring a stronger sense of Serbian nationalism. But in doing so he was also accused of stirring resentment that some nationalists expressed with violence.

Some of Mr. Cosic’s theories about Serbian nationalism and democracy in Yugoslavia were promoted by Slobodan Milosevic, the Communist leader of Serbia, beginning in 1989. Mr. Milosevic’s embrace of Serbian nationalism eventually helped set off almost a decade of Balkan warfare, costing an estimated 200,000 lives and resulting in his trial for war crimes, crimes against humanity and genocide. (He died in his cell during the trial in 2006.)

For a time, Mr. Cosic expressed support for Mr. Milosevic, but he also questioned Mr. Milosevic’s commitment to Mr. Cosic’s stated goal of creating a democratic region.

“My main criticism of Milosevic is his slowness to support political reform,” Mr. Cosic told The New York Times in 1990.

A self-described moderate with no party affiliation, Mr. Cosic was elected president of Yugoslavia by its Federal Assembly in June 1992. It was unclear from the beginning how powerful he would be and what his plans were. The Yugoslav federation had dwindled to just two republics, Montenegro and the recently formed Republic of Serbia. He was 70 at the time, and Mr. Milosevic, the president of Serbia, was widely understood to control what remained of the federation.

Mr. Cosic appeared to seek an elusive middle ground, saying in his acceptance speech that he wanted “peace and cooperation with all neighbors, the United States and the whole world community,” but also that he supported Serbs fighting in Bosnia and Herzegovina and in Croatia, actions opposed internationally.

Asked in a televised interview whether his rise meant the end of Mr. Milosevic’s dominance, he replied, “This is not in my competence to say.”

The following spring, Mr. Cosic and Mr. Milosevic embraced a United Nations plan for peace in the region.

“The conditions of this plan are not ideal, and in fact they are painful,” Mr. Cosic told the Serbian Assembly in May 1993. “The plan is imperfect and unjust. But it gives us a chance to achieve our goals through peace instead of war. The world is against us, and we cannot continue this war to the point of committing suicide. We have no strength for this war. We cannot continue fighting this war.”

But Serbs rejected the deal, and less than a month later, at the beginning of June, Mr. Milosevic orchestrated Mr. Cosic’s ouster.

Dobroslav Cosic was born on Dec. 29, 1921, in the village of Velika Drenova. Information about survivors was not immediately available.

During World War II, he joined the Communist resistance to German occupation. After the war, as a government official, he was in charge of propaganda. He developed close ties with President Tito and for two decades was an ardent promoter of Yugoslav unity.

But in 1968, Tito removed him from the Communist Party Central Committee for speaking out against the treatment of Serbs and Montenegrins in Kosovo, a province where Albanians made up the vast majority.

“I have to thank Tito for banning me,” he told The New York Times in 1990. “It gave me time to write.”

In a complicated region, Mr. Cosic’s role was complicated, too. In 2000, when a student group called Otpor formed to protest Mr. Milosevic’s policies, Mr. Cosic, nearly 80, decided to join.

Political commentators took note of his continued effort to distance himself from Mr. Milosevic, even as he was accused of enabling his brutal rule. A drawing by a prominent cartoonist, Corax, showed Mr. Cosic scrubbing himself clean in a bathtub with a hand curled into a fist, the Otpor symbol of resistance. Unlike the fist in the real Otpor symbol, however, Mr. Cosic’s had been reduced to the bones of a skeleton.

A version of this article appears in print on , on Page A22 of the New York edition with the headline: Dobrica Cosic, 92, Friend Then Foe of Serbia’s Milosevic. Order Reprints | Today’s Paper | Subscribe