Prodded by the Clinton administration, the warring factions in Bosnia yesterday agreed to a nationwide cease-fire and Camp David-style peace talks in the United States as a step toward ending their brutal 42-month-old conflict.

The cease-fire agreement will take effect at one minute after midnight on Oct. 10, provided full gas and electricity supplies have been restored to the Bosnian capital Sarajevo, which has been under siege by Serb separatist forces since the beginning of the war. The American-sponsored peace talks are scheduled to begin at the end of October, to be followed by a full-scale peace conference in Paris.

Announcing the agreement in the White House briefing room, President Clinton described the cease-fire as "an important moment in the painful history of Bosnia." He said the accord greatly increased the chances of ending the war and achieving peace, even though "deep divisions" remained to be overcome.

Yesterday's eight-point agreement between the Muslim-led Bosnian government and the Serbs capped two months of intensive diplomatic effort by the United States to find a negotiated solution to the worst fighting in Europe since World War II. Last month, the two sides agreed to a set of constitutional principles that provide for a common Bosnian parliament and presidency but effectively confirm the division of the country along ethnic lines.

The final details in the agreement were hammered out overnight following a day of exhausting shuttle diplomacy that involved negotiations in Sarajevo and the Serbian capital of Belgrade by an American team headed by Assistant Secretary of State Richard C. Holbrooke. According to U.S. officials, it was made possible by a last-minute change of heart by the Bosnian government, which earlier had been holding out for greater concessions from the Bosnian Serbs but experienced some significant military reverses this week.

Holbrooke said in a telephone interview that he told Bosnian President Alija Izetbegovic in Sarajevo on Monday that he was "playing craps with the destiny of his country" because he was still hesitating about signing on to an immediate cease-fire. "If you want to let the fighting go on, that is your right," Holbrooke said he added, "but do not expect the United States to be your air force."

The United States helped to level the battlefield in favor of the Bosnian government at the end of August by leading its NATO allies in staging a series of airstrikes on Bosnian Serb positions. The airstrikes were called off two weeks later after the Bosnian Serbs agreed to pull heavy weapons out of a 12-mile exclusion zone around Sarajevo, and relax their siege of the capital.

Holbrooke secured Izetbegovic's agreement in principle to the U.S.-drafted document when he returned to Sarajevo on Wednesday. He then flew to Belgrade for a six-hour negotiating session with Serbian President Slobodan Milosevic. Four hours later, Milosevic informed Holbrooke that he had persuaded Bosnian Serb leaders Radovan Karadzic and Ratko Mladic to sign the agreement.

Leaders from all sides hailed the agreement for a cease-fire, which is to last at least 60 days, as Bosnia's best chance of securing a lasting peace since the beginning of the war in April 1992. More than 50 partial and general cease-fires have been signed over the past 3 1/2 years, but few have lasted more than a few weeks. What makes the latest agreement different is that the rival factions have fought themselves to an effective stalemate, and the military and political prestige of the United States is on the line.

Speaking to reporters in Sarajevo, Izetbegovic described the cease-fire as "a serious agreement" that would be respected by all sides.

U.S. officials said they expected Izetbegovic and Milosevic to lead their countries' delegations to the U.S.-sponsored peace talks later this month. Croatian President Franjo Tudjman is also expected to attend, but the level of Bosnian Serb representation is not clear. Karadzic and Mladic would run the risk of arrest if they came to the United States, as they have been indicted by an international tribunal in The Hague for war crimes.

U.S. officials expect the peace talks to follow a pattern similar to that of the 10-day Camp David session, hosted by President Jimmy Carter in 1978, which led to a preliminary accord between Egypt and Israel on the return of the Sinai Desert. They will take place in a secluded location, away from reporters, with U.S. officials shuttling among the different delegations and occasional face-to-face talks.

The major difference from Camp David is that there are no plans for a prominent role for Clinton, who has so far steered clear of direct public involvement in the Bosnian peace process. Even though Clinton has gone before television cameras to announce the latest diplomatic successes, he still seems wary of identifying himself too closely with the still-uncertain outcome of the Bosnian peace talks.

State Department spokesman Nicholas Burns said the peace talks would be co-chaired by Holbrooke, European negotiator Carl Bildt, and Russian Deputy Foreign Minister Igor Ivanov. U.S. officials are eager to give the Europeans a prominent role in the talks, as the European Union will be expected to pay a large share of the bill for post-war reconstruction in Bosnia.

The Clinton administration is also looking for ways to involve Russia in the implementation of a future peace agreement, and is sending a delegation led by Secretary of Defense William J. Perry to Geneva to meet with Russian Defense Minister Pavel Grachev on Sunday. Russia has historical ties to Serbia and is expected to help police the peace agreement, although its exact role remains to be worked out.

The United States has promised to contribute up to 25,000 troops to a 50,000-strong NATO force to separate the warring factions once a peace agreement comes into force. Perry told CNN that U.S. troops could be spending Thanksgiving in Bosnia, but other officials expressed skepticism that a peace agreement could be concluded by then.

The progress toward peace caused the United Nations to announce that it would cut its presence in Bosnia by 9,000 troops, or by a third. It did not give a timetable for the withdrawals.

The key issues to be worked out in peace talks include a territorial division of Bosnia between the Bosnian-Croat federation and the "Srpska Republika," or Serb Republic. The two sides have agreed to a 51 percent-49 percent split, but there are likely to be land swaps to provide the Bosnian government with better access to Sarajevo and Gorazde, and to facilitate communications between Serb-held territory in eastern and northwestern Bosnia.

The cease-fire agreement includes a provision for an exchange of prisoners of war and the opening of two access roads to Gorazde: one via the Serb-held town of Rogatica, and another via Belgrade. It commits the two sides to stop all offensive operations, reconnaissance activities, firing of heavy weapons and sniper activity, and laying of mines.

In Sarajevo, Izetbegovic showed reporters an additional undertaking signed by Holbrooke committing the U.S. side to push for a resumption of NATO airstrikes in case of Serb attacks on Sarajevo and other U.N. "safe areas." The statement said Washington would consider any attempt by the Serbs to cut off electricity and water supplies to Sarajevo as serious cease-fire violations.

Restoring Sarajevo's electricity supplies by Oct. 10 will present a major challenge for U.N. peacekeepers, who will have to clear dozens of land mines from the electricity grid near Kiseljak in Croat-controlled territory. To restore gas supplies to Sarajevo, U.S. and Bosnian officials had to plead with the Russian company Gasprom to overlook $100 million in unpaid bills by Serbs and Muslims.

The final round of Holbrooke's negotiations with the Bosnian government took place in the building where Austrian Archduke Franz Ferdinand lay in state in 1914 after his assassination by a Bosnian Serb, an act that precipitated World War I. It followed swearing-in ceremonies for the new U.S. ambassador to Sarajevo, John Menzies, in what Holbrooke described as "a house that reeks of history's failure." After hours of negotiations with Bosnian government leaders, Holbrooke then flew to Belgrade for another six hours of talks with Milosevic, which lasted until 2:30 a.m. yesterday. U.S. officials kept an open telephone line to the American negotiating team in Sarajevo to clear last-minute changes with the Bosnian government.

"Milosevic would wander in and out of the office, and sometimes get on the line himself," Holbrooke recalled. Last-minute negotiations included such matters as to whether the Serbs would agree to permit two or three access roads into Gorazde. They eventually agreed to only two.

The Bosnian Serb representatives were standing by in a villa in Belgrade, waiting to be summoned by Milosevic. The Serbian leader, who has been authorized to negotiate on behalf of the Bosnian Serbs, secured their signatures to the cease-fire agreement several hours after Holbrooke and his colleagues had gone to bed.

Holbrooke then flew back to Sarajevo to present the document to Izetbegovic, and then to Zagreb to brief Croatian President Tudjman. The Croatian leader accepted the agreement, but objected to the proposed date of Oct. 25 for beginning of peace talks because he has scheduled snap elections for then to capitalize on recent military successes. The U.S. side agreed to delay the peace talks until Oct. 30. Correspondent John Pomfret in Sarajevo and staff writers Ann Devroy in Washington and Dana Priest in Williamsburg, Va., contributed to this report.