Kandahar, the second largest city in Afghanistan, is largely in the hands of Moslem guerrillas, who have government posts on the defensive and frequently under siege, according to a free-lance photographer who spent most of last month in and around the city.

Soviet troops are rarely seen in the southern Afghan city, but stay outside it at the heavily guarded airport, said Terence White, 35, of New Zealand.

A similar situation prevailed in the third largest city, Herat, at least as recently as October, according to Dominique Vergos, a French photographer who emerged then from more than a year of traveling with the guerrillas in Afghanistan. Vergos said armed Afghan guerrillas known as mujaheddin were able to ride around openly in jeeps, and he estimated that they controlled about three-fourths of Herat, a city in western Afghanistan near the Iranian border that is rarely visited by westerners.

The accounts of White and Vergos during visits to Bangkok last week indicated that more than five years after the Soviets invaded Afghanistan, they face growing problems in trying to crush the Moslem guerrillas and build up the Moscow-installed government of Babrak Karmal.

The mujaheddin long have been reported to have effective control of the countryside, with the Soviet occupation troops -- estimated to be 115,000 -- dominating the cities and major roads. But the descriptions by White and Vergos of such a tenuous grip on the two largest cities after the capital, Kabul, point to potentially serious problems for the Soviets and their Afghan government proteges.

Afghan guerrilla leaders interviewed across the Pakistani border in Peshawar earlier this month said the fighting in Kandahar had been the fiercest of any winter since the Soviet invasion in 1979. Although the leaders said they were in control of most of Kandahar Province, the resistance forces have been hampered by several factors.

Gulbaddin Hekmatyar, who heads the fundamentalist Hizbi Islami group that has units fighting in Kandahar, said the Soviets are shifting their attacks from the central provinces to border provinces such as Kandahar. Their air raids, he said, have been disrupting the flow of food, ammunition and -- most important now -- warm clothing.

The photographers described extensive Soviet air operations, including almost daily strikes on Kandahar and surrounding villages by bombers and helicopters, as the Soviets appear to rely increasingly on their unmatched air power. Despite reports of an increasing flow of arms to the guerrillas from foreign donors, the guerrillas still lack sufficient antiaircraft weapons with which to resist the Soviet air strikes, the photographers said.

White said he left for Afghanistan from neighboring Pakistan with a convoy of eight jeeps in which the mujaheddin were carrying arms, ammunition and other supplies into the Kandahar area. He said that while they drove mostly at night through the desert, switching off headlights when approaching government posts, they occasionally -- to his surprise -- used main roads without incident.

In the countryside, armed mujaheddin even traveled freely on public buses carrying their Kalashnikov rifles, White said.

On entering Kandahar, White said, he found normal day-to-day activities in the city's bazaar area, with shops selling flat loaves of Afghan bread, meat, fruit, vegetables and other items, while armed guerrillas walked around casually.

Outside one tea shop, White said, an Afghan was cleaning a light machine gun. He said that when he asked the guerrillas what would happen if a patrol of Soviet or Afghan soldiers came into the bazaar, the mujaheddin laughed at what they regarded as a naive question.

"They don't, because they would be captured or killed," he quoted Mullah Mohammed Zay, a local commander from the Jamiat-i-Islami guerrilla organization, as saying.

White said that on another occasion, a guerrilla commander pointed to a government post in the western part of Kandahar from about 100 yards away and told him, "Two meters on each side belongs to the post. The rest belongs to the mujaheddin."

White said he was told there are about 30 posts in the city manned by government troops and an Afghan Army garrison on the northwestern edge of the city, but that Soviet forces were concentrated at the airport, about seven miles southeast of Kandahar.

From there, he said, the Soviets mounted almost daily air strikes in and around the city, using jets and helicopter gunships.

"The day I went into the bazaar, two helicopter gunships were firing into the city," White said. He said mujaheddin also told him the Soviets often fired barrages from rocket launchers into Kandahar. During the air strikes, he said, the Afghan government posts fire flares into the air to mark their positions and avoid being hit.

"Every day I was in the city there was bombardment," White said.

White said he was told that the population of Kandahar, formerly about 150,000, was now down to 10,000 to 20,000, most of the inhabitants having fled to Pakistan as refugees. While life went on fairly normally in some areas, like the bazaar, he said, other neighborhoods of Kandahar were deserted and many shops in the city were closed.

The photographer said that whenever he asked guerrilla commanders about American aid, the usual reply was, "Where is it?" He said the mujaheddin repeatedly stressed that they had nothing effective with which to combat the Soviet air attacks.

White said the guerrillas can move fairly freely in the parts of the city he visited, adding that the Afghan troops are largely confined to their posts and must be resupplied by heavily armed convoys and sometimes by air. In the countryside around Kandahar, he said, the Soviets also must travel in big convoys and often cross open deserts to avoid mujaheddin ambushes on the main roads.

Although White's account of normal food sales in the Kandahar bazaar seems at odds with the description by rebels in Peshawar and Afghan exiles arriving in New Delhi, it is possible that food supplies are reaching the large cities but not the rural areas, according to western diplomats in Kabul.

Reports received from Kandahar's rural areas and passed on by the resistance in Peshawar say that the Soviet and Afghan Army's air attacks have seriously disrupted the economy in those areas.

They say armored units attack a village, shoot cattle, burn crops and foodstores and tear up terraced fields. Then, the exiles say, the Army plants explosive charges in the underground irrigation channels dug in the hillsides and leading to the fields, or bombs the surface irrigation ditches.

In Herat, according to French photographer Vergos, guerrillas led by Ismail Khan, a former Afghan Army officer, held similar sway, and government forces were bitterly divided between the rival communist Parcham and Khalq factions that make up the Babrak government in Kabul.

The Afghan Army continues to be riddled by defections, Vergos said. In one incident while he was in Herat, he said, an Afghan Army officer arranged with the mujaheddin to defect with a tank, and one day drove it out of his garrison and headed for a guerrilla zone. Government forces tried to recover the tank, but could not find it, Vergas said. Washington Post correspondent William Claiborne, who was in Peshawar recently, contributed to this story from New Delhi.