Soviet Foreign Minister Eduard A. Shevardnadze apologized yesterday for the shooting of a U.S. serviceman by Soviet soldiers during a patrol in East Germany, but he said both Americans and Soviets were at fault in the incident.

Shevardnadze alleged that two members of the U.S. Military Liaison mission were taking pictures and "gathering radio and electronic intelligence" near a restricted Soviet aircraft facility when Soviet soldiers fired "warning" shots.

Pentagon officials described a different scenario and said the shooting that injured the American serviceman was "totally unjustified."

Defense Department spokesman Robert B. Sims said the two Americans were driving in an unrestricted area near a small town in northeastern East Germany when they spotted a man clad in a black overcoat, black beret and black tennis shoes watching them.

"The leader had a gut feeling it was in fact a Soviet soldier, and he decided they should leave," Sims said.

They then spotted another man, who was attired identically, reach for an automatic rifle on the ground nearby. About the same time, three more men, one wearing a Soviet uniform, appeared.

As the Americans attempted to speed away, seven shots were fired in their direction, acccording to the Pentagon account. A fragment of one bullet caused a superficial wound in the left forearm of the driver, Air Force Master Sgt. Charles L. Barry of Tucson, who remained hospitalized in West Berlin yesterday, Sims said. Another bullet shattered a window in the jeep-type vehicle, he said.

Sims said he had no evidence that the two Americans were taking photographs or gathering intelligence, as Shevardnadze alleged.

The Soviet soldiers surrounded the vehicle when it stopped and detained the two Americans for about 20 minutes. Air Force Capt. Bennett McCutcheon of Scottsdale, Ariz., demanded that the Soviets lower their weapons and allow him to give water and first aid to Barry, Sims said. He said the Soviets eventually complied, then allowed the two men to drive away.

"The action of both the U.S. and the Soviet soldiers in this case are a violation of the agreement on military liaison missions . . . in occupation zones of Germany," Shevardnadze told reporters here yesterday. He declined to elaborate.

The foreign minister added, "At the same time, we are conveying our apologies on what has happened, and we state that the Soviet side will take necessary steps to rule out, to exclude the possibility of any such incident in the future."

"This was a serious incident that had nearly tragic results," Sims said, adding that the U.S. government has lodged protests with the Soviets.

The incident, which occurred about 9:15 a.m. EDT Thursday was the most serious between American and Soviet troops in East Germany since March 1985, when a Soviet soldier shot and killed Maj. Arthur D. Nicholson. At that time, the U.S. government also said Nicholson was in an unrestricted area and had been shot for no sufficient reason.

As a result of that shooting, the Soviets and Americans negotiated an agreement intended to prevent similar incidents.

The military liaison missions were formed by the United States, the Soviet Union, Britain and France after World War II to improve cooperation among the four occupying powers in Germany.

The teams of the four nations are permitted to move freely throughout East Germany, except in certain restricted zones. The primary mission of all four groups today is to gather information on each other's military activities.

Although Shevardnadze did not say the Americans were in a restricted zone, he alleged they were "very close to . . . the area which is prohibited to members of foreign military missions."