A security guard shot and killed a man following an alleged knife attack on an elderly man at a Palmdale McDonald’s on Sunday afternoon, witnesses said.

The violence took place about 4:30 p.m. at the restaurant at 2427 E. Avenue S.

Juan Paiz, who owns the involved security company, Paiz Patrol, said he was still gathering information.

The attacker had crashed a car into a nearby Carl’s Jr. restaurant prior to heading to the McDonald’s and stripping off his clothes, according to officials and witnesses.

“(He) apparently started stabbing several patrons,” Paiz said. “At that point, security approached him. He tried to stab a security officer and the security officer defended himself by firing his service weapon.”

The attacker stabbed an 88-year-old man who was eating with his grandson, Los Angeles County Sheriff’s Department Lt. Brandon Dean said. The victim was in stable condition.

The wounded suspect, described as a 29-year-old man, was taken away in an ambulance. He was pronounced dead at a hospital a short time later, officials said.

Deputies found the suspect’s knife at the scene, according to Deputy Tracey Koerner of the Sheriff’s Information Bureau.

Irvin Diaz said he was nearby when he heard gunshots and ran over to see what was happening.

He said he saw a security guard standing over the wounded man, who was naked.

Video footage from the scene showed a car had struck a nearby Carl’s Jr. restaurant.