SUNNYVALE, CALIF., FEB. 16 -- A former employee of a Silicon Valley defense contractor fatally shot seven persons today and wounded five others at the company's offices, including a woman who had spurned him, authorities said.

The man, identified by police as Richard Wade Farley, 39, surrendered after barricading himself inside the building for about six hours. Three officers grabbed him as he walked out with his hands in the air, and he was taken to the Santa Clara County Jail in nearby San Jose.

Employees dived under desks and inside closets as the gunman shot his way into the two-story ESL Corp. building, witnesses said.

As the siege continued into the evening, police negotiators talked by telephone with the man, who "expressed a little remorse" for his actions, said Lt. Tom Moore of the Sunnyvale Public Safety Department.

Seven persons were killed, said Alex Michaelis, commander of the safety department. They were not immediately identified.

The gunman, who was fired from the company three years ago, had called police and said he shot three persons on the first floor "and as many on the second floor," said Capt. Al Scott of the safety department. He was armed with a rifle and a shotgun, Scott said.

One woman was listed in critical condition; two others were in good condition. The condition of two other victims was not immediately available.

At least three persons had been reported holed up in a computer room and were making telephone calls to police, while others were able to escape.

The shooting began about 2:30 p.m. at the subsidiary of TRW, about 40 miles south of San Francisco, near San Jose.

"I saw a man walk up and I didn't really pay attention and then just shortly later I heard bang, large bangs, and I realized it must be shots," said witness Norma Kessler, who hid in her office.

"I was in the office by myself and I closed the door and it locked and I got underneath my desk and I must have heard about 50 different shots over a period of time. I must have been in there maybe 20 minutes, something like that."

Nearby, police found a motor home, filled with explosive materials, that they believe was driven by the gunman.

One of those wounded was the woman who had spurned the gunman, Scott said. The two were never believed to have dated, he said.

Moore identified the woman as Laura Black, who he said had been a target of Farley's affections for about four years. Farley, who worked at ESL as a computer software technician, reportedly followed Black and Black had tried to obtain a restraining order to keep him away, he said.