A 29-year-old Youngstown, Ohio, man was shot and killed by security police inside the Pentagon's River Entrance early yesterday after he pulled out a pistol and tried to enter an area near the Pentagon "war room," according to military and law enforcement officials.

Dwain Wallace was shot once in the back as he fled toward a hall near the National Military Command Center used by the Joint Chiefs of Staff, officials said. Military spokesmen said that Secretary of Defense Caspar W. Weinberger and Secretary of State George P. Shultz were meeting in a room one floor above the shooting site and heard the gunfire.

Pentagon spokesmen said the officials were not considered in danger.

"There was no disruption of work," said Col. Joe Parker, a Pentagon spokesman. "We're just down the hall. There was a momentary 'gee whiz,' but no disruption of our activities."

According to Wallace's parents, he had been undergoing treatment for mental illness for about four years. They would not say what the illness was. Leroy and Doris Wallace told reporters for The Youngstown Vindicator that their son had been confined to an Ohio state hospital for more than three years and had lived the past four months in a halfway house for the mentally ill.

"He probably had grandeurs about being someone he wasn't," Doris Wallace said. "He thought he was a general."

Wallace was taken to the National Hospital for Orthopaedics and Rehabilitation in Arlington with massive internal bleeding. Wallace died in the operating room about 10 a.m., according to a hospital spokesman. No one else was injured in the incident.

Officials said the last fatal shooting in a federal government building here was in June 1985 when a 20-year-old man smuggled a rifle into the State Department, shot and killed his mother, who worked about 120 feet from Shultz's office, and then fatally shot himself in the head.

Yesterday's incident began just after 8 a.m. when Wallace entered the building "mumbling something about missiles," said one Pentagon official.

When security police with the Federal Protective Service told him he could not enter without an identification badge, he walked past the security station, pulled a small caliber handgun and pointed it at one of the officers, Sgt. C.R. Creditt, officials said.

According to an officer with the FPS, Creditt backed away and fell over a stand-up ashtray. Officer Shirley Bastine, who was also on duty, yelled at Wallace, distracting him and allowing Creditt to pull his gun, according to an FPS officer.

Wallace then turned and raced several yards down the hall toward the double glass doors leading into the offices of the Joint Chiefs of Staff and the National Military Command Center, officials said.

Creditt fired two shots, one of which lodged in the bulletproof glass of the guard booth just inside the double doors, the other hitting the intruder in the back, according to a FPS officer. Creditt was placed on administrative leave pending an investigation by the FPS and the FBI.

Sources said Wallace's FBI record shows that he was convicted of aggravated assault on June 26, 1980, after an April 27, 1979, incident in the New Orleans suburb of Gretna.

Law enforcement officials said yesterday it was unclear when Wallace arrived in the Washington area or what his reasons were for entering the Pentagon.

Wallace's father, Leroy, said that his son had told him Monday that he planned to leave Youngstown to look for a job in Pittsburgh. Wallace's parents said they had not heard from him since.

Acquaintances and family members described Wallace as a man who had enjoyed a happy, well-adjusted youth, but who had been struck by mental illness shortly after his graduation from high school in 1976. Since then, Wallace's parents said, he had been unable to cope with the pressures of daily life.

Wallace grew up in a comfortable, middle-class section of Youngstown and attended Cardinal Mooney High School, a Roman Catholic institution. Administrators at the school recall Wallace as affable and outgoing. They said he was an above-average student and a member of the student council.

"He was a pleasant-type kid, always smiling," said Don Bucci, the school's football coach.

"He played intramural basketball during his junior and senior years, and I refereed a lot of the games. He was well-adjusted, got along well with the other students. A nice kid."

According to Wallace's parents, Wallace changed radically at about age 19, when, they said, he began suffering from mental illness. In 1977 and again in 1978, he failed to complete classes at Youngstown State University. Later, he began to claim, falsely, according to his parents and military officials, that he had served in the Marines.

"My son was never in the service but he always wanted to be," Doris Wallace said. "When he began to experience mental problems he just couldn't function."

Wallace was confined at Woodside Receiving Hospital, a state-run mental hospital in Youngstown, around 1983, his parents said. About four months ago, they said, he was released from Woodside and voluntarily checked himself into the Doris E. Burdman Home in Youngstown, a halfway house for those with psychological disorders.

The Wallaces said their son married and divorced. He fathered a daughter. He had not worked in recent years. Wallace's father said he had no knowledge of his son's owning a gun.

Staff writers Molly Moore, Elizabeth Lazarus and Marc Lacey contributed to this report.