POWAY, Calif. — A 19-year-old gunman opened fire inside a synagogue near San Diego as worshippers celebrated the last day of a major Jewish holiday, killing a woman and wounding the rabbi and two others Saturday, authorities said.

President Donald Trump and other elected officials decried what they called an anti-Semitic attack exactly six months since 11 people were killed at a Pittsburgh synagogue in the deadliest assault on Jews in U.S. history.

An off-duty Border Patrol agent working as a security guard at the Chabad of Poway fired at the shooter as he fled, missing him but striking his getaway vehicle, San Diego County Sheriff William Gore said.

The gunman, identified as John Earnest, used an AR-type assault weapon, Gore said. There were indications that the gun might have malfunctioned after firing numerous rounds inside the synagogue, the sheriff said.

Shortly after fleeing, Earnest called 911 to report the shooting, San Diego Police Chief David Nisleit said. 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.

A girl and two men were wounded as the Jewish congregation gathered for Passover, a weeklong commemoration of the deliverance of the ancient Hebrews from slavery in Egypt. The three were in stable condition, authorities said.

Earnest has no criminal record, but investigators were looking into a claim he made in an online manifesto about setting a fire at a mosque in nearby Escondido last month, Gore said. There was damage but no injuries.

Gore said authorities were reviewing copies of his social media posts and were investigating the attack as a possible hate crime.

A person identifying themselves as John Earnest posted an anti-Jewish screed online about an hour before the attack that contained some elements not to be believed, like an allegation a YouTube star helped plan and fund the shooting. The post says he was in nursing school and cited the suspects accused of carrying out deadly attacks on mosques in New Zealand last month and at Pittsburgh’s Tree of Life synagogue Oct. 27.

There was no known threat after Earnest was arrested, but authorities boosted patrols at places of worship as a precaution, police said.

Minoo Anvari, a member of the synagogue, told media outlets that her husband was inside during the shooting. She said he called to tell her the shooter was shouting and cursing.

She called the shooting “unbelievable” in a peaceful and tight-knit community.

“We are strong; you can’t break us,” Anvari said.

Donny Phonea, who lives across the street from the synagogue, turned off his power drill and heard someone shout, “Police!” Then he heard three or four shots.

The 38-year-old bank auditor looked over his backyard fence facing the synagogue and saw people hiding behind an electrical box in the parking lot of a neighboring church. At that point, he knew something was “very, very wrong,” went inside and closed his doors and garage.

“I’m a little taken aback,” said Phonea, who moved to Poway two weeks ago. “I moved here because safety was a factor. Poway is very safe.”

Trump offered his sympathies Saturday, saying the shooting “looked like a hate crime” and calling it “hard to believe.” The mayor of Poway, who tweeted that he got a call from the president offering help, also denounced what he called a hate crime.

“I want you know to you this is not Poway,” Mayor Steve Vaus said. “We always walk with our arms around each other and we will walk through this tragedy with our arms around each other.”

Democratic Gov. Gavin Newsom said he joins the community in grief.

“No one should have to fear going to their place of worship, and no one should be targeted for practicing the tenets of their faith,” he said.