Bloodied but unbroken, the Soviet Army begins pulling out of Afghanistan on Sunday amid threats of guerrilla harassment and grave doubts about the future of the Marxist government it leaves behind.

On the eve of the withdrawal, the Soviet commander in Afghanistan denied his men had been defeated in the brutal war that has claimed an estimated 10,000 Soviet lives.But politically, the fruits of the 81/2-year Soviet armed intervention seem meager. Militarily, the Soviet presence has proved far from decisive.

Since Dec. 27, 1979, when the Kremlin sent tanks and troops into Afghanistan, Soviet soldiers have been fighting to prop up the People's Democratic Party of Afghanistan, but they have failed to break the back of a nationwide anti-Marxist insurgency.

Acknowledging the Kremlin's unwillingness to keep bearing the military and diplomatic costs of the intervention, Foreign Minister Eduard A. Shevardnadze signed U.N.-brokered accords in Geneva on April 14 that commit the Soviets to a nine-month pullout, beginning Sunday.

As the first of an estimated 115,000 Soviet troops prepare to come home, one major question is how - or if - the Moscow-aligned regime of President Najib, which claims just 40,000 regular soldiers of its own, can survive.

The first Soviets to leave will be from a motor-rifle division garrisoned at Jalalabad, a dusty provincial town 30 miles from the Pakistan border, military officials and Soviet media have said.

Lt. Gen. Boris V. Gromov, Soviet commander in Afghanistan, said Saturday more than 1,000 soldiers would leave Jalalabad on Sunday and that a quarter of the entire Soviet contingent would be home by the time President Reagan visits Moscow on May 29-June 2.

In recent days, Soviet media have issued alarming reports about increasing guerrilla activity, perhaps to ready public opinion for losses during the withdrawal, or to stress that the pullout will heighten the likelihood of bloodshed among the Afghan factions locked in a 10-year-old civil war.