A U.S. Army sergeant was wounded Wednesday when the helicopter in which he was flying took ground fire from a squad of guerrillas on the Pan American Highway near a strategic bridge east of the capital, U.S. Embassy spokesmen said today.

Special Forces Staff Sgt. Jay T. Stanley of Towson, Md., is the first U.S. soldier injured by rebel fire in the two years since American military trainers arrived here to help the army Washington backs in a civil war against leftist insurgents.

The incident comes as the guerrillas and government forces are waging widespread offensives. Stanley's helicopter was fired on only about 10 miles from the city of Berlin, which was captured by the rebels earlier in the week and held until yesterday evening, when they reportedly made a tactical retreat.

U.S. officials were careful to say that the Green Beret radio operator had broken none of the rules prohibiting U.S. advisers from entering combat here.

They described Stanley's condition as good and said that the wound from a 7.62 mm bullet in his upper left leg is expected to heal sufficiently for him to be back on duty in two weeks. He is being treated at the military hospital in the capital.

"We weren't doing anything wrong," Stanley said from his bed in a San Salvador hospital, according to The Associated Press. "I wouldn't want to be in a situation like that again. We came under heavy fire."

Embassy spokesman Donald Hamilton said this evening that the American UH1H helicopter in which Stanley was flying was mounted with at least one 60-caliber machine gun and that a door gunner also was wounded. His name and condition were not immediately available.

According to Hamilton, there were three other American soldiers in the helicopter during the shooting but none of them was injured.

The group had flown out to the Cuscatlan bridge across the Lempa River at about 9 a.m. Wednesday to repair a radio relay station used for military communication, Hamilton said. They were in the air and about to return to San Salvador when a traffic tie-up was spotted on the Pan American Highway about 2 miles east of the bridge.

As the embassy explained today, the Salvadoran helicopter pilot, whose name was not immediately available, took it on himself to investigate the problem on the road and brought the helicopter to a lower altitude to get a clearer view.

That particular section of the highway is the frequent scene of guerrilla roadblocks and skirmishes with the Army, especially in the three weeks since the rebels launched their latest offensive.

Hamilton said he does not know if the helicopter's door guns were fired at any time during the encounter. Although the M60 machine guns mounted on El Salvador's "Hueys" are designed to be used mainly for defensive purposes, it is common here for these Vietnam-vintage helicopters to be put into action as makeshift gun ships as well as general utility vehicles.

Embassy spokesmen said there are 37 American advisers in this country, and there is a ceiling of 55 advisers here at any one time. Stanley's wounding comes as some U.S. officers are advocating lifting the ceiling.

Several Western military observers involved with the war effort here believe the Salvadoran Army is increasingly on the defensive and that there is little chance in their view of turning the situation around until the Army receives more advice at more levels of command structure.

The Associated Press added the following:

Col. Jaime Flores, who commanded the Cuscatlan Batallion that retook Berlin, said about 1,600 troops entered the city just before dawn, then moved south to retake the small towns of San Agustin and San Francisco Javier.

Two government soldiers and 60 guerrillas were reported killed during the guerrilla retreat.

A foreign military observer said an Air Force fighter strafed a column of 200 rebels five miles west of Berlin, and troops ferried in by helicopter attacked on the ground.

Foreign observers said the capture of Berlin demonstrated the rebels' increasing ability to operate on more than one front and the necessity for the Army to switch from large-scale infantry sweeps to highly mobile counterinsurgency tactics.

Col. Domingo Monterrosa, commander of the U.S.-trained Atlacatl Battalion, said his troops were pulled out of an Army offensive in Morazan province to the north to help recapture Berlin.