U.S. military personnel were caught between Salvadoran soldiers and attacking guerrillas two weeks ago and fired on the rebels, in the first shooting incident involving Americans in 18 months, the Pentagon said Tuesday.

Army Maj. Kathy Wood said three U.S. advisers were acting in self-defense when they fired their M-16 rifles at rebels who attacked the Salvadoran army's 4th Brigade headquarters at El Paraiso Sept. 13.The spokeswoman said this was the first time U.S. military advisers had fired their weapons since March 31, 1987, when guerrillas attacked the same base. Army Staff Sgt. Gregory Fronius was killed in that exchange, Wood said.

President Reagan, in New York where he addressed the U.N. General Assembly, agreed with the assessment by Pentagon officials.

"They were obeying orders," Reagan said of the U.S. military personnel. "I'll never send any of our people into danger without allowing them to defend themselves against attack and they were attacked."

A U.S. official said, "They found themselves in a situation where they felt their lives were in jeopardy and responded appropriately under the rules of engagement."