ISLAMABAD, Pakistan (AP) _ A renegade Afghan general who tried to overthrow the government of Afghanistan fled with his family to Pakistan today, Pakistani and guerrilla sources said, giving weight to government claims the coup attempt had been crushed.

Gen. Shah Nawaz Tanai, the battle-hardened defense minister linked to three coup attempts against the Soviet-backed government in Kabul, flew aboard an Afghan military helicopter with his wife, two daughters and a son to the frontier town of Peshawar, said the sources, who demanded anonymity.

According to guerrilla sources, Tanai left Bagram air base at 2 p.m. Earlier reports said mutineers had seized control of Bagram, Afghanistan's largest air base. The Afghan government had denied those reports, and the situation remained unclear late today.

The sources said Tanai contacted Gulbuddin Hekmatyar, a fundamentalist Afghan guerrilla leader, before fleeing and that one of Hekmatyar's commanders had been with Tanai since the coup attempt was launched Tuesday.

Such an alliance would be more one of convenience and opportunism than ideology. Tanai, a Marxist hard-liner, has long advocated a harsh stance against the U.S.-backed guerrillas and opposed President Najib's attempts to make peace with them.

At the same time, the radical fundamentalist Hekmatyar has become increasingly estranged from his fellow Moslem guerrilla leaders, rejecting their political leadership and executing some of their followers.

Pakistan should be a safe haven for Tanai, as its government strongly opposes the Najib government.

Earlier today, a foreign diplomat said mutinous soldiers, who had the support of guerrillas, had seized control of Bagram, 30 miles north of Kabul.

A government spokesman denied it but acknowledged fighting at the base.

Western diplomats and guerrilla leaders in Pakistan said they also had reports of fighting between rival factions in the southern city of Kandahar and the northwestern city of Herat.

The diplomats and guerrilla sources, all speaking on condition of anonymity, also told of sporadic street fighting in Kabul, the capital, and said mutinous air force pilots bombed the capital for a second day but were repulsed by loyalist troops.

Afghanistan's highest-ranking diplomat in Pakistan, Charge d'Affaires Qudratullah Ahmadi, denied there was widespread fighting. ''There is only fighting in Bagram. All of Afghanistan is quiet,'' he told reporters in Islamabad.

Of the Bagram battle, Ahmadi said, ''This was a strong challenge. This was their (the mutineers') last chance.'' He denied the base had fallen.

But a foreign diplomat said, ''All indications are that the mutineers are in control of Bagram.'' The diplomat added: ''Beyond that, the situation in Afghanistan is exceedingly unclear.''

Claims made by the Kabul government and the Moslem insurgents are often exaggerated and impossible to verify independently.

In a brief speech today on official Radio Kabul, Najib again claimed victory over the mutineers and said renegade soldiers were surrendering. ''Tanai has escaped. His allies are defecting, and those who do not surrender will be punished,'' he said.

Radio Kabul said troops loyal to Najib controlled Kabul, a city of 2 million, but urged residents to stay indoors.

It also accused another high-ranking party member, Asadullah Sarwari, of involvement in the attempted overthrow. Sarwari was a former interior minister known as ''the butcher'' for hundreds of killings following the 1978 revolution that installed the Communist government.

The whereabouts of Sarwari was not immediately known.

Najib, who was installed as president by the Soviets in December 1986, said ''a number of people,'' mostly civilians, had been killed and injured since Tuesday. He gave no figures.

The government appealed to supporters to take up arms in defense. Hekmatyar, leader of one of the most fundamentalist of the guerrilla groups that took up arms against the government 11 years ago, claimed six Soviet warplanes joined the government's fight. A Soviet official denied it.

Hekmatyar offered his support to the mutineers within hours after planes began bombing the presidential palace Tuesday afternoon.

A spokesman for Hekmatyar said Tanai's forces controlled the Kabul airport today but were under heavy rocket attack.

Western diplomats and U.N. officials in Pakistan backed the report and said the Chinese, Italian and Indian embassies had been slightly damaged.

Those sources also claimed troops loyal to Najib were pounding the air base in Bagram, trying to rout Tanai's supporters. Radio Kabul, monitored in Islamabad, said Najib had ordered the air force to bomb Bagram.

Guerrilla sources and Pakistani officials claimed three high-ranking Afghan generals flew a transport plane to the Pakistan border and surrendered to the guerrillas. One guerrilla source said the soldiers supported neither side and did not want to stay in Afghanistan.

Western diplomats and guerrilla sources said they also had reports of Afghan helicopters and warplanes landing at towns along the border. They said they did not know who was on the aircraft.

Moscow withdrew its soldiers from Afghanistan in February 1989 after a nine-year military intervention in the war, but it continues to ship arms to the Afghan armed forces.

Hekmatyar, speaking in Pakistan, claimed Moscow sent six warplanes from the bordering Soviet republic of Tadzhikistan to bomb Bagram. He said one Soviet warplane was shot down.

A political officer at the Soviet Embassy in Islamabad denied the allegations.

Tanai and Hekmatyar were linked to at least of two of the five previous reported attempts to oust Najib, who took office in 1986. Tanai belongs to a faction of the ruling party that is a bitter rival of Najib.

He is said to have had many contacts with Moslem guerrillas who took up arms after the 1978 coup that brought the Communists to power.

Hekmatyar told reporters Tuesday in Islamabad that he supports any attempt to oust Najib. If a coup succeeded, he said, the guerrillas would decide whether to negotiate for an Islamic government or fight Najib's successor.

Hekmatyar, a 42-year-old engineer, has has been accused by other resistance groups of killing rival guerrillas and innocent civilians and broke away from the government-in-exile formed by the guerrillas after the Soviet withdrawal.