An off-duty federal security officer was shot and seriously wounded last night as he went to the aid of a Safeway store employe who was being held hostage by a gunman following an aborted robbery of the store, D.C. police reported.

The robbery attempt, which occurred about 9 p.m in the Safeway at 2626 Naylor Rd. SE, set off a wild scramble and near panic when the 65 customers and employes in the store began diving for cover from gunfire and the two robbers tried frantically to avoid detection by mingling with the shoppers.

"We were all just real scared," said 17-year-old Marilyn Dyson, a customer, "especially when we saw this guy with the gun." Dyson said she was even more frightened after the shooting had stopped, when plainclothes police officers searching for a suspect still hiding among the shoppers ordered everyone in the store to come out with hands up.

"I didn't know what was going on," Dyson said. "I thought it was the robbers and they were going to take us all hostage."

Another customer, Andre Warr, 16, said most of the frightened shoppers gathered near the produce counter at the back of the store. "There were mothers and little children all huddled together; people were crying and screaming," Warr said.

D.C. police officials gave the following account of the incident:

About 9 p.m., Richard A. Simms, 39, an off-duty Federal Protective Service sergeant who was shopping at the time, noticed two men surreptitiously enter the store manager's office.

Simms approached store cashier Melvin Mitchell, 38, whom he knew to be an off-duty D.C. police sergeant working part time, and told him he thought the office was being robbed. Mitchell told Simms to call for police help from a telephone outside, and then shouted to the customers and other employes to go to the back of the store and "Get down."

Just then, the robbers, who had forced a store employe to give them an umdetermined amount of money from the safe, emerged from the office. The first, who was unarmed, came out carrying a bag of money and ran immediately to the back of the store where he tried to hide among the crowd of customers; the second robber came out brandishing a pistol and was ordered to halt by Mitchell, who had drawn his service revolver.

The gunman also fled to the rear of the store as Mitchell fired one shot, which missed. Mitchell then went outside where he took cover behind a bush near where Simms was on the telephone with police.

Moments later the gunman came out the front door, holding a meat department employe in front of him and pointing the pistol at the man's head. Almost immediately, police said, Simms leaped at the gunman and during a struggle was shot once in the left side as the employe escaped.

The gunman then ran into a nearby woods as Mitchell and two plainclothes officers who had been staked-out in a nearby carry-out shop fired several shots at him. A two-hour search of the woods was unsuccessful, police said, but a second man was later arrested as the crowd of shoppers and employes was led from the store.

That suspect, identified as Arther P. Moore, 18, of 3300 C. St. SE, was charged with armed robbery and was being held for arraignment. Police said the money taken from the safe was recovered inside the store.

Simms, an 11-year veteran of the FPS, which provides security for federal office buildings, was listed in serious condition early today at Greater Southeast Community Hospital.

John N. Jester, chief of FPS operations for the national capital region, said Simms was promoted to sergeant about a year ago and now supervises a squad of 15 to 20 men at buildings in Washington and Prince George's County.

"He's just the kind of man who would try to help somebody in trouble," Jester said of Simms.

About three years ago, Jester said, Simms helped save the life of a pedestrian who was run down by a speeding getaway car at 18th and E streets NW. Simms was on duty at the Interior Department near the scene when a car occupied by four bank robbery suspects careered onto the sidewalk and struck 47-year-old Alvin Biscoe, severing one of his legs and crushing the other.

Simms ran to the scene, Jester said, and used his belt to apply a tourniquet to Biscoe's severed leg until paramedics arrived. Biscoe was later rushed to a hospital where both his legs were amputated, but he survived.

For his efforts in the incident, Simms was given the Distinguished Service Award of the General Services Administration.