One woman has died and three others — including a young girl — were injured in the horrific synagogue shooting.
Earnest allegedly fled in a car and called 911 shortly afterward to say he was involved in the shooting, San Diego Police Chief David Nisleit told reporters.
When an officer reached the man on a roadway, "the suspect pulled over, jumped out of his car with his hands up and was immediately taken into custody," Nisleit said.
San Diego County Sheriff William Gore told reporters an off-duty Border Patrol agent believed to be inside the synagogue shot at the suspect as he fled. The sheriff says the agent didn't hit him but struck his car.
There was no known threat after Earnest was detained, but authorities boosted patrols at places of worship as a precaution, Nisleit said.
A rabbi was shot in the hand during the incident as worshippers heroically rushed to intervene, according to NBC.
The local mayor described at the attack as a "hate crime", NBC reports.
US President Trump offered his condolences to the victims. At the White House, Trump said that the shooting ''looked like a hate crime'' and called it ''hard to believe.'
Minoo Anvari told CNN that she's a member of Chabad of Poway and her husband was inside during the shooting. She said he called to tell her the shooter was shouting and cursing and she called the shooting "unbelievable" in a peaceful and tight-knit community.
"We are strong, we are united, they can't break us," she said.
The shooting came on the last day of Passover and exactly six months since a shooting at a Pittsburgh synagogue killed 11 people.
A truck driver who authorities say expressed hatred of Jews has been charged in the deadliest attack on Jews in US history. He's pleaded not guilty to the October 27 rampage at the Tree of Life synagogue.