UNITED NATIONS, NOV. 10 -- Despite an intensive Soviet diplomatic campaign, the U.N. General Assembly today approved for the ninth year a resolution calling for "the immediate withdrawal of the foreign troops from Afghanistan."

The vote was 123 to 19 with 11 abstentions, up from last year's 122 to 20 with 11 abstentions.

The defeat was a setback for a three-month-long Soviet drive to forge a new image in the United Nations and take the initiative in using the institution as a catalyst for settling regional disputes such as that in Afghanistan.

However, amid an annual debate that was more bitter than ever, there were hints of a new attempt to break the negotiating stalemate in U.N.-sponsored proximity talks between Afghanistan and Pakistan that began in 1982. The new effort would involve launching an "all-party" dialogue on self-determination that would exclude the Soviet-backed government in Kabul but embrace all elements of Afghan society, including representatives of the 5.5 million refugees who have fled the country since the 1979 Soviet invasion and of the indigenous Marxist party, the People's Democratic Party of Afghanistan.

Today's vote came as a special U.N. investigator recommended the withdrawal of the 115,000 Soviet troops as a "precondition" for self-determination and full human rights for the Afghans. The report by Austrian jurist Felix Ermacora, appointed by the U.N. Human Rights Commission, proposed that Afghan rebels have the status of prisoners of war. After a visit, Ermacora concluded that rights violations in government-held areas have declined, but that they have intensified in combat areas and spread farther into Pakistan.

In this year's debate, for the first time, the Soviets offered amendments designed to neutralize Pakistan's traditional resolution on Afghanistan, but these were withdrawn at the last moment when Pakistan threatened to insert language even more unpalatable to Moscow.

The new "all-party" dialogue now under consideration, according to diplomats close to the process, would take place outside the country, without preconditions, and would include the coalition of seven leading rebel groups plus "prominent" exiles.

The diplomats said U.N. mediator Diego Cordovez would now test the possibility of bringing these elements together, directly or indirectly, in the next few months. Until now, the U.N. talks have involved only Kabul and Islamabad, plus informal consultations embracing Washington, Moscow and Tehran. Cordovez is to meet informally for the first time Wednesday night with Yunis Khalis and other leaders of the Alliance of Afghan Refugees.

Proponents of the new talks hope that launching such a process would enable Moscow to shorten its timetable for completing a troop withdrawal to less than a year. So far, Moscow has offered 16 months, while Pakistan has insisted on eight months. This remains the only formal obstacle to an agreement.

But diplomats said that in practical terms there must be some link between the withdrawal timetable and the process of creating a provisional coalition government. They said Moscow realizes that the U.N.-envisioned process would exclude the current Kabul government and relegate the domestic Marxist party to a subsidiary role at best. "The Russians don't care" about the Marxists, said one diplomatic source. "They say they just want a government that can prevent a massacre in Kabul and ensure a smooth withdrawal."