The rifle fire that flared briefly near the center of this war-torn city one morning, this week lasted only a few minutes.

Although darkness made it impossible to determine the outcome of the clash, probably between Moslem guerrillas and an Afghan Army patrol, it provided one clear message: another day in the battle for Herat, Afghanistan's third-largest city, had begun.

Unlike the situation in Afghanistan's two largest cities, Kabul and Kandahar, where rebel bands emerge mainly at night to harass and snipe at government targets, the war here is a 24-hour-a-day affair, waged between demoralized remnants of the Afghan Army and an assortment of well-armed ragtag guerrilla groups that have managed to seize and hold key areas of this city of 85,000 in western Afghanistan, about 80 miles from the border with Iran.

The warren of narrow streets and lanes that make up the four-square-mile old walled city, for example, is completely in rebel hands.

Guerrillas stop and search taxis, rickshaws and pedestrians entering or leaving the old city, often demanding identification.

Repeated efforts by President Babrak Karmal's government forces to wrest the enclave from the rebels have failed.

Armored vehicles, unable to maneuver within the confines of the old city streets, have proved easy prey to rebel antitank weapons.

Despite almost continuous fighting during the two days this reporter and Time magazine correspondent Marcia Gauger were in the city, no Afghan or Soviet helicopter gunships or jet aircraft appeared overhead.

Elsewhere in Herat, the Soviet-supported Afghan government appears to be slowly losing its grip. By day, it exercises only tenuous control in most areas. Small-arms fire and the "crump crump" of Afghan Army tank guns in action have become part of the city's background noise.

Unless the fighting is close, few even bother to take note of the sounds.

Herat's police commandant said that he could guarantee no one's safety at any time, anywhere in the city. A lesser government official elaborated: "Nowhere is secure. If you walk up a couple of blocks, you may be safe, then again maybe not."

By night, Herat becomes a no-man's land with various areas under control of whoever can muster the most firepower. The few government armored patrols that venture into the city center after dark usually move at high speed. But the fighting is not always between the government and rebels. The lack of any real government control has made it an ideal environment for rival tribal groups to settle old blood feuds. Bitter infighting and vendettas within the ruling People's Democratic Party are also common here as thoughout the country.

There is no curfew in Herat as there is in other Afghan cities because the government is incapable of enforcing one. But when dusk falls, the streets quickly empty.

In addition to the frequent, sharp skirmishes each night, the rebels and government forces engage in psychological war.

Brilliant red tracer bullets fired into the air from rebel weapons arch out of the old city, symbols of defiance. Government troops, stationed on the ramparts in the ancient citadel that still looks down on the city from the hills where Alexander the Great built it 2,300 years ago, counter by sweeping searchlights across the town -- more to frighten than actually spot guerrillas.

The success of the antigovernment insurgency here, greater than in any of the country's major cities, is a measure of the depth of anti-Soviet hatred permeating Herat.

Eighteen months ago, about 40 Soviet advisers reportedly were killed here during the first major revolt against the country's Marxist government. Since that time, few Soviets have ventured into Herat.

With the Marxist rulers under increasing pressure from Moslem rebels last year, the Soviet Union intervened at the end of 1979, sending approximately 80,000 Soviet troops into Afghanistan and battling the rebels across the country, using armored vehicles, helicopter gunships and other modern weapons against the guerrillas.

Soviet troops man checkpoints at the entrance to Herat, but do not enter the city itself. Convoys coming south into western Afghanistan from the Soviet Union skirt the city to the east.

A near-suicidal resistance to foreign occupation is deeply etched into Herat's history. In the 13th Century, the city was conquered by Genghis Khan but soon revolted. The entire Mongol garrison, including Genghis Khan's son, was killed. Enraged, the Mongol leader besieged the city until only 40 people remained alive.

Just over a century later, the Asian conquerer Tamerlane destroyed Herat after it rose up against his rule.

So far at least, the Soviets have resisted temptations to extend this cycle, although there is little question that they have more than enough military power to crush the resistance. Some blame the Soviet inaction on reluctance to accept the high number of casualties such an operation would entail. Others speculate that the price of the resulting bloodbath in terms of world opinion would be too high.

The depth of antigovernment feeling makes it especially dangerous for the small minority of People's Democratic Party cadre who restrict themselves to "safe" areas of the city.

Much of the Afghan Army force in Herat is said to be stationed around the offices and residences of the top party functionaries, usually located in remote areas.

"Nobody supports the government here, not even 1 percent of the people are for them," one resident said.

While it is impossible to determine just who and how many have died in the months of fighting, there is one certain casualty: Herat itself. It is a city whose life is slowly ebbing away.

Even at the height of the working day, many shops in the main bazaars around the famous Masjedi-i-Jami Mosque remain closed. Other traders say the owners have abandoned their businesses and fled to either Iran or Pakistan.

As conditions continue to deteriorate, despair and a feeling of helplessness grip those who remain. However, with little real reason, most cling to the belief that someday soon, in some way, Herat's agony will end.