An Afghan soldier and a civilian were reported killed when several hundred Afghans stormed a prison near here today demanding the release of political prisoners held by the new Soviet-installed rulers.

Diplomats and travelers said Afghan Moslem guerrillas and bandits, fighting far better equipped Soviet troops, managed to cut major highways in at least two parts of the country this week as reports continued to reach the capital of widespread opposition to the two-week-old invasion.

Meanwhile, Babrak Karmal, the Afghan Communist leader installed as ruler here by the Soviet-engineered coup, told reporters in a contentious press conference Thursday that the Soviet troops will remain in Afghanistan until the United States, China, Pakistan, Egypt and Saudi Arabia end their "aggressive policies" toward this country.

Two Western reporters who were at the Policharki Prison 15 miles east of Kabul said the attack by demonstrators came when about a hundred political prisoners were being released.

About 3,000 Afghans, most of them relatives of men imprisoned by Babrak's overthrown and slain predecessor, had gathered after announcments by the government that large numbers would be freed.

When only a small number were brought out, the reporters said, hundreds of the relatives stormed the prison gates, and guards and Afghan soldiers opened fire.

Observers said the incident seemed to confirm diplomatic reports that only a fraction of the estimated 12,000 to 15,000 political prisoners have been released despite Babrak's pledge of a general amnesty and his declaration that 10,000 had been freed already.

Diplomats said the major Moslem guerrilla attack on Soviet vehicles came earlier this week on a U.S.-built stretch of highway about 145 miles north of Kandahar, a provincial capital in southern Afghanistan.

About 60 to 70 Soviet vehicles were destroyed with land mines, the diplomats said, in what apparently was the first time that the anticommunist rebels have used mines in their 18-month war against a succession of leftist central government.

Between Kabul and Jalalabad, travelers said, guerrillas or bandits killed at least three Soviet soldiers, ambushing their vehicles by blocking the road with felled trees.

Fighting between Soviet troops and rebels was continuing in the northeast, diplomats said, and there were unconfirmed reports that the Soviets were engaging in search-and-destroy missions to annihilate Moslem guerrilla opposition.

Babrak's news conference yesterday was the first to which Western journalists have been invited since he came to power. Most accounts of the conference by Western news agencies could be transmitted.

Throughout the 90-minute press conference, Babrak repeatedly dodged questions about the number of Soviet troops in Afghanistan and the extent of his support among the population.

He termed the U.S. estimate of 85,000 Soviet troops here as "obviously an exaggerated figure" but he refused to give his own number.

He also avoided direct answers to questions about who had invited Soviet troops into the country and what proof he has to back his allegations that the United States, and not the Soviet Union, had supported his rival communist predecessor, Hafizullah Amin.

Babrak insisted that "a very limited contingent of Soviet military troops is here as a precaution against possible foreign invasion of Afghanistan's sacred soil." He also mentioned the "havoc and destructive policies of Chinese and American imperialism" as reasons for the influx of Soviet troops.

He insisted that not "even one" Soviet soldier has been killed, wounded or captured in fighting here, and he would not acknowledge any conflict between Soviet forces and Moslem Afghan insurgents or renegade Afghan troops.

The crowded press conference at his heavily guarded Chilsitoon Palace south of the capital featured friendly questions from Soviet and other communist correspondents. A coterie of supporters in the front rows applauded his denunciation of Western governments and news media.

Given the widespread public resentment of the Soviet invasion, observers here had expected Babrak at least to give lip service to a nationalistic and independent position. But he repeatedly and effusively lauded the Soviet Union.

"What is more brilliant than the sun is that the Soviet Union is regarded as the most honest friend of all people of the world," he said.

Asked when and under what circumstances Soviet troops would pull out of his country, Babrak said, "They will leave Afghanistan the moment the aggressive policies of the United States, in compliance with the Peking leadership and provocations from reactionary circles in Pakistan, Egypt, and Saudi Arabia, are eliminated."

Babrak denied that Amin, whom he called "a renowned agent of American imperialism," had requested the dispatch of Soviet troops to Afghanistan. He claimed that the request was made by "the legitimate revolutionary council of Afghanistan," a body that was not formed until after the Soviet invasion had put Babrak in power.

From the start of the news conference, Babrak adopted a belligerent attitude toward Western reporters. In opening remarks he greeted correspondents "from friendly countries" and those "from the opposition."

Asked by a British correspondent to substantiate claims that he had been "democratically elected," Babrak began his reply, "Mister representative of British imperialism . . ."

Challenged to estimate what percentage of the Afghan population supported him in view of popular opposition to the Soviet military presence, Babrak responded by denouncing the questioner's new organization, the British Broadcasting Corp., as "the most famous propaganda liar of the world."

Press buses that wound through the spacious grounds of Chilsitoon Palace to the presidential residence had seen, positioned on the palace lawn with its barrel pointing toward the main entrance, a Soviet-made light tank of the kind airlifted to Kabul for the Dec. 27 coup. The buses also passed a Soviet-supplied antiaircraft battery and an armored personnel carrier.

The palace was guarded by a contingent of Afghan troops carrying Kalashnikov automatic rifles. Burly plainclothed guards, apparently Soviets watched over the news conference.