A masked gunman rammed his Lincoln Continental through glass doors of an IBM Corp. office building near Montgomery Mall in Bethesda yesterday and sprayed dozens of rounds from an automatic weapon, killing two men and wounding seven other persons.

The gunman, identified by police as Edward Thomas Mann, 38, of Mitchellville in Prince George's County, a former IBM employe, held off police for more than 7 1/2 hours before surrendering peacefully.

During sporadic negotiations throughout the afternoon, Mann claimed in telephone conversations--with police, his wife and a psychologist--that he was holding several hostages in the three-story glass and steel building. But when he surrendered at about 6:40 p.m., it was learned he had none.

Montgomery police chief Bernard Crooke said that the siege ended after Mann's wife, Rosa, entered the building with police. "All he wanted was for his wife to hear his voice," the chief said.

After talking to her through a closed door outside the third-floor office where he was holed up, Crooke said Mann made one final request: to empty his automatic weapon into a picture on the wall.

Crooke said he heard about 10 rounds being fired, and a moment later, the door opened and Mann walked out, leaving behind him four weapons--the automatic weapon that he used to terrorize IBM employes throughout the day, a shotgun and two handguns.

Crooke said Mann resigned voluntarily from IBM two years ago, and apparently had a grievance with the company over a workman's compensation claim. Ed Nanas, a spokesman for IBM, said corporation records showed that Mann was employed by IBM from July 1966 to December 1979. Another IBM spokesman said Mann was an advisory marketing representative who worked in Bethesda during the entire time of his employment and reported into the building that he took over yesterday.

More than 600 people were in the building when the gunman opened fire about 11 a.m. About 400 of them, many shouting at their coworkers that a gunman was in the building, escaped within minutes. The remaining 200 escaped throughout the afternoon. By early evening, police had evacuated everyone with the exception of the gunman and the "hostages" he claimed to be holding.

Cpl. Philip B. Caswell, a Montgomery police spokesman, said the bodies of the two dead men were left in the building throughout the afternoon, as police conducted a room-by-room search of the building.

The dead were identified as Hung Phi Nguyen, 40, of the 1000 block of Good Hope Drive, Silver Spring, and Larry Lewis Thompson, 56, of 9018 Stream View Lane, Vienna.

Police said Nguyen's body was found on the second floor and Thompson's on the third floor.

Mann was taken to the Montgomery County Detention Center in Rockville, where he was charged with murder, assault with intent to murder and lesser charges. He is scheduled to be arraigned Tuesday.

On Michele Lane south of John Hanson Highway in Mitchellville, where Mann had lived for years in a development of single-family houses, one man said that the suspect's neighbors "just can't believe it."

Mann was a "quiet guy," who caused no trouble, worked on his Corvette racing car in his carport and said little about his job, according to one neighbor.

The neighbor said he never knew of Mann owning a weapon.

All of the injured were taken to Suburban Hospital. Late last night, three men who were shot were listed in critical condition; four other men, including one who suffered a heart attack during the siege, were reported in stable condition; and one man injured wrestling with the gunman was in satisfactory condition. Two persons, including the only woman casualty, who was hurt when she fainted and fell, were treated and released.

The man who wrestled with the gunman was Erich Baumgartner, 48, of Rockville.

According to Kenneth Philbrook, assistant director of Suburban's emergency department, the gunman pointed one of his weapons at Baumgartner and pulled the trigger. Philbrook said Baumgartner told him there was no shot, just a click. Twice more the gunman pressed the trigger and nothing happened.

Realizing that the gun was empty, Philbrook said Baumgartner leaped up and wrestled with the gunman as he tried to reload. But as they struggled, the gunman managed to jam the butt of his weapon into Baumgartner's face.

Baumgartner suffered a broken nose and cuts over his eyes and on his hands.

At about 1:30 p.m., Pam Coulter, a reporter for radio station WTOP, talked by telephone for 7 to 8 minutes with a man who identified himself as "Edward Mann." Asked if he was aware of what had occurred, the man said, "I have no idea."

He added that, "I used to be" an employe of IBM, but that after 13 years as a systems engineer and marketing representative he quit about three years ago and has been unemployed since.

"The company is very prejudiced," the man said, adding that "they disguise it in a very business-like way." He added that after he quit, "IBM saw that I didn't get a job." The situation, he said, is "very complicated."

Told by the reporter that several people were in critical condition, he said, "I feel very heartbroken . . . very sorry." He then asked Coulter, "Pam, why don't you come and get me . . . I will be here."

By late afternoon, Montgomery police had identified the gunman and located him in a corner office on the top floor.

He had driven his copper-colored car up a ramp and into the lobby of the structure, dubbed the "Rusty Bucket" by IBM employes because of its brown metallic appearance, about 11 a.m. It is located just north of the Capital Beltway near Montgomery Mall and the Marriott Corp. headquarters.

Police said they negotiated with the gunman over an open telephone line with the assistance of Mann's wife, other relatives and a police psychologist. Caswell said that the gunman was "rational and coherent" throughout the negotiations.

One of the wounded, John F. McHale, 41, of Columbia, described the scene inside the building:

"I was standing at a window with another fellow and heard something behind me. I saw somebody standing about 80 feet away with what seemed like a rifle. I went down, as did the fellow behind me. There was a desk between us . . . . I could see feet moving. He was shooting as he came . . . . I tried to get my head and upper body under the desk. He fired several shots. I didn't notice I was hit until I looked at my shoulder."

McHale was treated at the hospital for a flesh wound and was released.

Chris Shaffer, a witness to the first moments of the shooting, said he was in his office when "I heard a crash. I ran out of my office into the hall. The guy had driven a car into the front of the building. He pulled out the gun and started firing" without saying a word.

John Dickenson, a 24-year-old man who works in IBM's systems management office, said the gunman started firing toward the right hand corner of the room, taking slow steps and moving his gun in a leftward direction, toward where he was standing. Dickenson said an office colleague was hit by one of the shots. The two of them, along with Shaffer, ran down a hallway.

Shaffer escaped through an emergency exit, while the wounded man ran into an office and hid underneath a desk. Dickenson said he barricaded himself into an office with about 15 others and for the next 45 minutes heard shots being fired at the opposite end of the building.

The gunman roamed through the building and one witness reported that he heard him command people to move.

As the siege unfolded, many of the workers who had fled from the building watched from behind police lines. Workers at a nearby office opened the lobby and provided coffee. Employes in nearby buildings, including the headquarters of the Marriott and Martin-Marietta corporations, watched from their windows and later offered rides home to workers, some of whom had left purses and suitcoats with car keys inside the IBM building.

More than 100 Montgomery, Maryland State, Rockville and U.S. Park police surrounded the building at 1040l Fernwood Rd.

While Montgomery police carried on sporadic negotiations with the gunman, relatives of employes who worked in the building frantically sought to find out their fate.

Janet Johnson, a senior program computer who works in the building, hurried to Suburban Hospital, fearing that her mother, Frances, who also works there as a receptionist-secretary, had been wounded.

As it turned out, Frances Johnson had fainted in the minutes after the shooting broke out, but revived and managed to escape. The two women were reunited at the hospital and warmly embraced before driving off.

Janet Johnson said she and 20 or 30 coworkers were working in the computer room on the ground floor when managers asked them to leave. As they fled, Johnson said they heard sirens wailing and spotted a Montgomery policeman crouched behind a tree with a rifle.

"That's when it clicked in my mind that something is happening here," Johnson said. "People were coming out whenever, wherever, for safety."