After several months of setbacks, Mozambican rebels have retaken the offensive and dealt a serious military blow to the fragile government of President Samora Machel, according to military and western diplomatic sources here.

The offensive has raised new doubts among western governments about Machel's future and forced Zimbabwe to reconsider its heavy commitment of troops to Mozambique, its neighbor and closest ally.

The key victory by insurgents of the Mozambique National Resistance movement was the recapture two weeks ago of Casa Banana, the movement's principal military headquarters, located in central Mozambique's Gorongosa National Park, about 75 miles northwest of the port of Beira.

Zimbabwean military sources said 400 insurgents stormed the camp on the night of Feb. 14, routing 1,000 Mozambican troops who abandoned armored vehicles, antiaircraft guns and large supplies of ammunition and fled virtually without a fight.

The military camp, which has its own airstrip, generators and workshops, had been seized last August by a combined task force of Zimbabwean and Mozambican troops. That highly publicized victory followed Zimbabwean Prime Minister Robert Mugabe's decision in July to commit between 10,000 and 15,000 Zimbabwean troops to Mozambique in an attempt to break the back of the rebel movement.

Despite his Marxist orientation, Machel's downfall would be a setback for the Reagan administration, which has built friendly ties with Maputo. Machel visited the White House last September, a trip that symbolized the detente between the two countries, although the administration has failed to persuade Congress to approve a token program of military aid.

The recapture of the camp has deeply angered the Zimbabwean military command, which has alleged that Mozambican troops there had not received supplies for three weeks before the rebel attack and were badly demoralized. Informed sources said Army officers privately were questioning the purpose of their mission in Mozambique, because many of their military gains were being reversed due to the Machel government's inability to hold onto territory.

"Many in the Army have drawn the conclusion that they can't win and they are wondering why they are there," said a western diplomat here.

Neither Zimbabwe nor Mozambique has publicly acknowledged the rebels' recapture of their camp, although the official Mozambican Information Agency has reported heavy fighting in the area.

The rebels have also stepped up attacks in the lower Zambezi River Valley, where some of the country's largest sugar estates are located. At least two plantations, which are among Mozambique's few earners of scarce foreign exchange, have been shut down recently.

The Mozambique National Resistance has also renewed attacks around Maputo, the Mozambican capital, attacking trains, buses and rail lines. Power lines from South Africa have been cut twice this year, and last week the government reported that seven bus passengers were shot to death and 20 wounded by rebels on the road from Maputo to neighboring Swaziland.

Zimbabwe has paid a heavy price financially for supporting its neighbor. While no figures on costs have been released, estimates run as high as 500,000 Zimbabwean dollars per day -- about $325,000 at current exchange rates. Mugabe traveled last December to the Soviet Union in part to seek military aid to help pay for the operation.

Since January, diplomats said, Zimbabwe has scaled back its operations, reducing its forces by several thousand and withdrawing to defensive positions along the Beira corridor and to a task force headquarters at Chimoio.

There were unconfirmed reports here that South Africa, which helped set up and sustain the insurgency between 1980 and 1984, may have contributed to the recapture of Casa Banana, which was built originally with its assistance.

The state-controlled daily newspaper Noticias in Maputo last week accused South Africa of "state terrorism" and said Pretoria has stepped up its support for the Mozambique National Resistance since last November.

South African Foreign Minister Roelof (Pik) Botha flew to Maputo Wednesday to discuss violations of the nonaggression pact the two countries signed in 1984.

South Africa has consistently denied aiding the rebels since the pact was signed, but Mozambique National Resistance staff diaries captured when Casa Banana was taken last year indicated that the movement was still receiving food and some weapons from Pretoria. South Africa has claimed these shipments were only "technical" violations, made with the knowledge of the Machel government