SAN DIEGO (AP) _ A man detonated bombs and opened fire with a shotgun Tuesday inside the offices of an electronics company that recently laid him off. Police said two executives were killed.

The assailant fled on a bicycle with a shotgun and a bandoleer of shells slung over his back, and a pistol stuffed in his waistband, but surrendered three hours later, police Lt. Dan Berglund said.

He said the man, 41-year-old Larry Thomas Hansel of San Diego, acknowledged involvement in the shootings at Elgar Corp.

Hansel surrendered at the Riverside County Sheriff's substation in Palm Desert, 75 miles northeast of San Diego. Deputies seized several weapons from him, Berglund said. When Hansel arrived, a bicycle was in the back of his blue pickup truck. Officers later cleared the area, fearing that explosives were in the vehicle.

Two homemade bombs were detonated inside the Elgar building and four other explosives that authorities characterized as ''very sophisticated'' were found unexploded behind it.

Hansel is a technician who had been laid off about three months ago because of cutbacks at Elgar, company officials said. Elgar has about 300 workers and makes computer components.

The assailant entered the building, set off at least two incendiary devices and blew out the telephone switchboard with a shotgun blast, said Chris Kelford, Elgar's chief financial officer. Kelford said he was trying to clear employees from the building when the gunman confronted him.

''He looked at me straight in the eye and told me to get out,'' Kelford said.

Hansel had gone to the building earlier in the day and had been asking who was in at the time, said Drummond Murdoch, chairman of Elgar's industrial electronics division. When he returned, Hansel said he was searching for three executives, Murdoch said.

One of the three officials was killed and a second hid in his office. It was not immediately known where the third man was at the time.

Both shootings took place inside second-floor offices of the two-story building, police said. The building is located in an industrial park housing many electronics and computer companies.

Murdoch and other employees identified the victims as John Jones, vice president and general manager, and Mike Krowitz, regional sales manager.

Murdoch said Jones was one of the three people Hansel had sought. Krowitz apparently was standing next to Jones and was shot three times.

Another one of the three, Tom Erickson, Elgar's director of human resources, said he hid in his office after hearing gunfire and shouts. He said employees tried to call police but couldn't because of the damaged switchboard.

After the initial explosions and gunfire, dozens of terrified employees ran out of the building. Many hid inside offices, under desks and behind file cabinets. Firemen later rescued one man who had escaped to the roof.

''It was very chaotic,'' engineer Don Deuel said. ''I did not see it all happen. I heard the shooting, and there was a lot of confusion with all the smoke.''

Inside the building, police found two bombs that had been detonated by remote control, Berglund said. Bomb experts found four more homemade bombs behind the building, including at least two Molotov cocktails, he said.

Kelford said one of the bombs inside the building started a fire with flames up to 15 feet.

Kelford said the gunman had a blank look in his eyes, spoke in an even tone and didn't seem distressed or excited.

Kelford said other employees indicated Hansel had made some ''unsettling statements'' in the past.

Police said they haven't determined a motive.

''We don't know why he came back but it was apparently to do some harm,'' Berglund said.

Tom Erickson, Elgar's director of human resources, said Hansel and about a dozen other employees were laid off about three months ago. Erickson said Hansel was a good technician but had poor work habits.