The United States and the Soviet Union have agreed to accelerate their efforts to find a compromise settlement to the war in Afghanistan following talks between Secretary of State James A. Baker III and Soviet Foreign Minister Eduard Shevardnadze in Berlin, a senior administration official said yesterday.

Baker and Shevardnadze, in a two-hour discussion at the Soviet ambassador's residence in East Berlin Friday night, agreed to convene a group of experts from both sides in Washington in the next few weeks to explore a possible settlement, the official said.

The major roadblock to a compromise has been whether President Najibullah, leader of the Soviet-backed Afghan regime, would remain in power in a transition period during which elections would be held. The United States has insisted that Najibullah step down during the transition period to ensure free and fair elections. But the Soviets have resisted ousting the Afghan leader.

Baker told Congress June 13 that only a "very, very narrow difference" separates the U.S. and Soviet positions.

In Berlin, "We agreed that we were indeed getting closer on Afghanistan and that what we would try and do is get the experts together," said the official, who spoke to reporters on Baker's plane as he returned to Washington yesterday from the six-nation conference on the future of Germany.

Baker and Shevardnadze are due to meet again July 17 and the official said the Soviets promised to "have someone in Washington who could engage with us on the nitty-gritty of where we were with respect to a possible Afghan-style election and a commission, and what the role of Najibullah would be in the course of the process."

President Bush and Soviet President Mikhail Gorbachev held a long discussion about Afghanistan at the Washington summit, which appears to have given a push to diplomatic efforts to resolve the stalemate between the Najibullah regime and the U.S.-backed Afghan rebels.

Although the Soviet foreign minister went to East Berlin with proposals that seemed to backtrack on the German issue, the senior U.S. official said Shevardnadze was interested in moving ahead on regional disputes. "He mentioned Cambodia, we mentioned Afghanistan," the official said.

U.S. officials have said the two sides are close to agreement on a set of principles to guide the transition to a peaceful settlement in Afghanistan. The principles include holding free and fair elections; setting up a credible mechanism to monitor and supervise the elections; and agreement that the United Nations and the Organization of Islamic Countries can supervise the elections during a transition period.

Questioned about Shevardnadze's proposal in Berlin that the four victorious World War II powers remain in a supervisory role over a united Germany, the senior official said the plan was intended for "domestic Soviet consumption," to offset hard-line criticism of Gorbachev. The Soviet leader faces a potentially difficult Communist Party Congress early next month.

The official said the United States was not concerned about aspects of the Soviet proposal rejected by the West. Shevardnadze "might have more flexibility after the party congress than he would before," the official said.