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 three 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.

The gunman, whose name was not released, used an AR-type assault weapon to shoot worshippers at Chabad of Poway, San Diego County Sheriff William Gore told reporters.

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, said authorities, who didn't release their names.

As the shooter fled, an off-duty Border Patrol agent who was inside the synagogue fired, missing him but striking his getaway vehicle in the city of Poway, just over 20 miles (32 kilometres) north of San Diego, Gore said.

The gunman called 911 shortly afterward 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.

Gore said he couldn't provide a motive while investigators interrogate the shooter, who is white. Authorities were reviewing copies of his social media posts.

There was no known threat after the man 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 neighbouring 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.

In Pittsburgh, a truck driver who authorities say expressed hatred of Jews has been charged in the Oct. 27 rampage at the Tree of Life synagogue. He's pleaded not guilty.