SAN JOSE, COSTA RICA, JAN. 13 -- President Oscar Arias today warned both the Nicaraguan rebels and the Sandinista government to stop their slide toward an escalated conflict or risk seeing a much-heralded Central American peace accord fail.

The warnings came in letters sent yesterday and today to three leaders of the anti-Sandinista rebels and to Nicaraguan President Daniel Ortega.

Arias first told three Nicaraguan rebel leaders living here to give up their armed struggle against the Sandinista government or move out of Costa Rica.

Then, in a letter sent tonight to Ortega, Arias called for greater "democratization" in Nicaragua and condemned the Sandinista government's plans for a military buildup, its failure so far to lift a state of emergency and its continued detention of prisoners who, Arias said, should benefit from reconciliation under the peace plan.

Expressing his "worries about assuring the success of the Central American peace plan" in view of a summit meeting Friday, Arias noted cease-fire negotiations have failed in the region's embattled states.

"The positions of the belligerents have been radicalized and intolerance . . . has grown," he said.

There is no room in Central America "to talk of militarization when we have committed ourselves to reducing our armies," Arias said. "There is no room to talk of keeping power indefinitely when we have committed ourselves to respect the free will of the people through voting." The latter comment appeared to refer to Ortega's recent remark in a speech that if the Sandinistas lost an election, they would "give up the government, but not the power."

The letter to Ortega appeared to be designed at least partly to balance the three letters sent last night to Alfonso Robelo, Alfredo Cesar and Pedro Joaquin Chamorro, three of the six directors of the Nicaraguan Resistance, the rebels' political alliance. They have been living in Costa Rica for several years after having left Nicaragua as a result of what they called Sandinista repression against political opponents.

The letters were delivered three days before Arias is to host a meeting of five Central American presidents here to discuss the fate of a regional peace plan that they signed last August.

Diplomats said Costa Rica came under sharp criticism from Nicaragua and its supporters during a meeting in Panama this week of an International Verification and Follow-up Commission, charged with evaluating the Central American peace plan.

The Costa Rican delegation was obliged to lobby hard to remove criticism of Costa Rica from the commission's final report, the diplomats said.

"The neutrality of Costa Rica and the sacred commitment of our people to peace cannot be mocked by anyone," Arias' letter said. "If you want to continue enjoying Costa Rican hospitality, you must desist from supporting the armed way. If not, I ask you to leave the country as soon as possible."

The letter added, however, that once the rebel leaders leave the country, Costa Rica would be available as a venue for peace negotiations in which rebel officials could participate. Arias said that "it hurts me" to expel the contra leaders, with whom he said he had developed friendships over the years.

{In Washington, an administration official said of the letter to the contras, "Either it's a complete appeasement of the Sandinistas, or he's setting up to take a tougher line with them. I fear it's the former . . . . There is no way for us not to be quite displeased."}

Rebel leader Cesar, asked about the letter as he returned to Costa Rica on a flight from Guatemala, said, "I guess we start packing our bags." He added that he considered himself a political exile and said he believed his expulsion would cause domestic political problems for Arias in view of Costa Rica's longstanding tradition of granting political asylum to exiles.

Cesar then went to confer with Arias, who confirmed his decision. Cesar said he probably would leave next week.

Robelo, who was on the same flight, appeared distressed by the demand and declined to tell reporters how he would respond. "It's a very delicate situation for me," he said. "My wife is Costa Rican, and I have to discuss it with her."

Cesar said he and others had met yesterday in Guatemala with leaders of Nicaragua's unarmed internal opposition to the Sandinistas and that they had agreed to invite Ortega to attend a "tripartite dialogue" during the summit meeting here Friday. Cesar said the internal opponents included representatives of six political parties, two labor unions and the Superior Council of Private Enterprise. The Sandinistas so far have refused to meet face-to-face with leaders of the rebels.

Arias, who won the 1987 Nobel Peace Prize for drafting and tirelessly promoting the Central American peace accord, has come under mounting Nicaraguan criticism for allowing contra leaders to live here.

Managua also has alleged that the contras have continued to use Costa Rican territory to launch or support attacks inside Nicaragua, in violation of the peace agreement.

Costa Rican officials have denied these charges and have made a special effort lately to show they are dealing resolutely with rebel activities discovered on their territory.

Costa Rican security officials last week launched a well publicized search for contra camps in the northern part of the country near the border with Nicaragua. No such camps were found, but officials announced they had discovered and shut down three clandestine clinics and detained about 20 rebels, some of them wounded.