A man who prosecutors say stabbed five people, two fatally, in a July 4 attack on a California beach town has been charged with murder. 

Logan Christopher Kelley, 26, was taken into custody after he allegedly approached a group of people in Huntington Beach and stabbed them with a knife.

He has also been accused of attempted murder, assault with a deadly weapon and battery on a police officer, the District Attorney's office said.

Kelley was charged under a provision known as 'special circumstance of multiple murders' - wherein if found guilty, he would be eligible for the death penalty or life without parole. 

Two people died and three others were wounded when a man armed with a knife began stabbing people during July 4 celebrations (scene is pictured)

 Two people died and three others were wounded when a man armed with a knife began stabbing people during July 4 celebrations (scene is pictured) 

Witnesses say the man jumped out of the vehicle and began swinging the knife at everybody around him, fatally wounding two people and injuring three others (scene is pictured)

 Witnesses say the man jumped out of the vehicle and began swinging the knife at everybody around him, fatally wounding two people and injuring three others (scene is pictured)  

According to officials, a group of people were watching fireworks in the street near the intersection of Pecan Avenue and 16th Street when the incident happened. 

Prosecutors claim that the accused was under the influence of alcohol and hallucinogenic drugs when he started stabbing people. 

During the rampage, Kelley allegedly stabbed Eric Hodges, 42, in the heart and William Collins, 47, in the lung and neck - which resulted in their death. 

The accused also stabbed two 35-year-old men as well one of the injured men’s 68-year-old father, according to the District Attorney's office.

In order to stop his murderous spree, nearby people including a 16-year-old boy detained him until cops arrived at the scene. 

Kelley was also charged with assaulting the boy, spitting on a police officer and using a racial slur while being arrested, prosecutors said. 

Police officers stand guard at the crime scene where police say multiple people were killed and injured in Huntington Beach

Police officers stand guard at the crime scene where police say multiple people were killed and injured in Huntington Beach

The accused, who is from a nearby town of Redondo Beach, is believed to not know any of the people he reportedly attacked.

Talking about the incident, Orange County District Attorney Todd Spitzer said: 'A day of celebrating America and all the freedoms we all enjoy turned into deadly chaos at the hands of a stranger.'

Kelley's arrest comes days after the FBI and Homeland Security warned Fourth of July revelers should be on high alert for possible lone wolf 'attacks' as they celebrate the holiday. 

The security agencies said solo attackers and small extremist groups pose the biggest threat, cautioning that large crowds are often seen as 'attractive targets.' 

Deeandre Adams was visiting friends for the 4th at the site of the attack, and was friends with the two men killed. 

'It's sad. It was horrible,' he told LA Times.  

He said a man pulled up in a car, jumped out and started stabbing everybody around him. 

Deeandre Adams was visiting friends for the 4th, at the site of the incident, when he said a man pulled up in a car, jumped out and started stabbing everybody

Deeandre Adams was visiting friends for the 4th, at the site of the incident, when he said a man pulled up in a car, jumped out and started stabbing everybody

A victim in a multiple stabbing is taken away as officers investigate the scene at the corner of 16th Street and Pecan Avenue in Huntington Beach

A victim in a multiple stabbing is taken away as officers investigate the scene at the corner of 16th Street and Pecan Avenue in Huntington Beach

Experts warn that high tensions across the nation due to the presidential election and the ongoing Israel-Hamas war are heightening the risks, and lone-wolf attacks are alarmingly hard to prepare against. 

'The police are being told by the FBI and Department of Homeland Security to be on watch for these types of things that are notoriously difficult to guard against,' security correspondent Aaron Katersky told ABC News

'The political environment of the country certainly doesn't help.'

The federal warning, which was also issued by the National Counterterrorism Center, urged police departments across the nation to be vigilant amid the celebrations. 

Although such bulletins are not uncommon before a national holiday, this July Fourth warning notably cites 'domestic' attacks that could be triggered by issues also including abortion and racism. 

Such terrorists would 'likely would use simplistic tactics and relatively easily obtainable weapons such as firearms, knives and vehicles.' 

The bulletin added that while the security agencies are not currently aware of any active plots to target the celebrations, attacks 'can occur with little to no warning.'