A veteran D.C. police officer was shot and wounded seriously yesterday when he walked into a downtown Washington delicatessen and liquor store while a robbery was under way, D.C. police said.

The officer, Robert B. Maring, 36, of the special operations division, was hit in the head and arm inside the M Street Delly at 1613 M St. NW before he could draw his service revolver, police officials said.

After shooting Maring, the robbers ran from the store and one of them fired two shots at two bystanders who pursued him through an alley. The bystanders were unhurt, and the robbers fled in a car parked a few blocks north, police said.

The officer, a policeman since 1972 who sometimes helps control traffic for presidential motorcades, was taken to George Washington University Hospital where doctors said he was undergoing surgery last night.

In a brief statement at the hospital, Police Chief Maurice T. Turner said that on first hearing of the shooting, he had "thought the worst," but that after hearing medical reports was "a little more optimistic that this officer will survive."

According to police, the incident began a few minutes after 3 p.m. yesterday when Maring, who was in uniform, pulled his police cruiser in front of the delicatessen to pick up lunch.

As the officer walked into the detached, one-story delicatessen, across M Street from National Geographic Society headquarters, Turner said, "unknown to him, there was a robbery transpiring."

According to police, two robbers, both armed with handguns, entered the store, announced a holdup and took money from one of the cash registers. They were about to empty the other when Maring came in.

One of the robbers wheeled and fired a shot at the officer, police said. Then, the second robber approached the officer, there was a brief struggle and more shots were fired. Police said they were not immediately certain which of the shots struck the officer.

The officer was shot in the left arm and in the left temple, police said. They said the bullet in the arm caused a compound fracture. It was believed that the bullet in the head did not penetrate the brain, and veered downward to lodge in the officer's neck. Authorities indicated that the officer did not lose consciousness.

The robbers fled from the store, ran along M Street for a few yards, then swerved into an alley leading north toward Rhode Island Avenue NW, police said. Two men, whose identities were not released, spotted one of them, running and glancing back over his shoulder. Suspecting that something was wrong, the men began to pursue him.

The robber fired two shots in the direction of his pursuers. Shortly afterward both robbers, reportedly clad in old Army fatigue shirts or jackets and dark trousers, were spotted in the 1200 block of 16th Street.

Police said they finally entered an automobile in the 1600 block of Corcoran Street NW, less than a half mile north of the shooting scene, and drove off. They remained at large late last night.

The wounded officer, detached yesterday to the Special Operations Division's special events branch to work with the motorcade, normally is assigned to the warrant detail in the tactical branch.