SAN DIEGO — A man walked into a Chabad synagogue near San Diego and opened fire, leaving one woman dead and three other people injured on Saturday, the last day of Passover.

The suspect, John T. Earnest, 19, of San Diego, was in custody, authorities said. Earnest is a student at the California State University San Marcos, the school's president said.

"This individual was with an AR-type assault weapon and opened fire on the people inside the synagogue," said San Diego County Sheriff Bill Gore said.

Danny Almog was inside the synagogue when the gunfire erupted and people went to the floor.

"And I look to the entrance and I see a guy — he was like 5'6, 5'7, white, with like glasses with a vest on and I think it was an M16," Almog told reporters. “And he was just standing there, like shooting, shooting, shooting everybody."

Almog said he started screaming for his kids, who were in another room. His father-in-law grabbed one of his children and ran. A friend, Almog Peretz, "grabbed all the kids in his hands and was just running, running towards the exit."

Almog called Peretz, who he said was shot in the leg while escaping with the children, a hero. He said they fled through a back door.

As the gunman fled the Chabad of Poway, an off-duty Border Patrol agent in the area fired at him, hitting his car, Gore and San Diego Police Chief David Nisleit said at a news conference.

Nisleit said a San Diego police officer was en route to the scene when he overheard on a scanner that a suspect had called the California Highway Patrol to report that he was involved in the shooting and gave his location.

The officer went to the location and “clearly saw the suspect in his vehicle, the suspect pulled over, jumped out of his car with his hands up and was immediately taken into custody" Nilsei said.

Police saw a rifle sitting on the front passenger seat, he said.

Sheriff's detectives and FBI investigators were examining a possible link between the suspect and a March 24 arson fire at a mosque in Escondido, a city just north of Poway. Authorities said graffiti left at the scene of the fire referenced the March 15 attack in New Zealand that killed 50 Muslim worshippers.

"We’re currently working with the Escondido Police Department and the FBI to determine Earnest’s possible involvement in the arson at the mosque in Escondido about a month ago," Gore told reporters.

Among the four people shot was a 61-year-old woman who died, said Michael Katz, a trauma surgeon at Palomar Medical Center. A girl and two men, including a rabbi who was shot in the hand, were stable, he said.

Gore, who called the shooting a "senseless act of tragedy," would not release details of the suspect or a possible motive, saying he is being interviewed by police and the FBI.

Poway Mayor Steve Vaus said in a phone interview with MSNBC that “it was a hate crime, and that will not stand."

"We are grateful to those in the congregation there that engaged the shooter and prevented this from being a much more horrific incident," Vaus said.

Members of the Chabad synagogue hug as they gather near the Altman Family Chabad Community Center, Saturday, April 27, 2019 in Poway, California. Hayne Palmour IV / The San Diego Union-Tribune via AP

Chabad of Poway had advertised an 11 a.m. "Passover Holiday Celebration" online. Saturday is the traditional weekly day of Jewish Sabbath,, and this Saturday was also the final day of Passover, a week-long holiday marking the deliverance of the Jewish people from slavery in ancient Egypt.

"My deepest sympathies go to the people that were affected, their families, their loved ones,” President Donald Trump said Saturday.

"Obviously it looks right now, based on my last conversations, it looks like a hate crime," he said.

Vaus tweeted that Trump called him from Air Force One and offered assistance.

Thoughts and prayers to all of those affected by the shooting at the Synagogue in Poway, California. God bless you all. Suspect apprehended. Law enforcement did outstanding job. Thank you! — Donald J. Trump (@realDonaldTrump) April 27, 2019

The Chabad synagogue serves as a community center for ultra-Orthodox Jews, and Chabads in general are known for reaching out to non-Orthodox Jews to encourage them to partake in Jewish life and join some celebrations.

In October, a man fatally shot 11 people at the Tree of Life synagogue in Pittsburgh. Suspected gunman Robert Bowers, 46, is charged with federal hate crime and other charges.

Poway is a city of around 50,000 north of San Diego.

"I want you to know, this is not Poway. The Poway that I know comes together just as we did a few weeks ago, in an inter-faith event,” Vaus said at a news conference. "We always walk with our arms around each other, and we will walk through this tragedy with our arms around each other."

Law enforcement in other cities, including Los Angeles, San Francisco and New York, said they were closely monitoring the situation.

The United States Holocaust Memorial Museum in Washington said it is “is shocked and alarmed at the second armed attack on a synagogue in the United States in six months.”

"Now our thoughts are with the victims and their loved ones," Museum Director Sara J. Bloomfield said in a statement.

"But moving forward this must serve as yet another wake-up call that antisemitism is a growing and deadly menace,” she said. "The Holocaust is a reminder of the dangers of unchecked antisemitism and the way hate can infect a society. All Americans must unequivocally condemn it and confront it in wherever it appears."

Israeli Prime Minister Benjamin Netanyahu condemned the shooting, calling it "an attack on the heart of the Jewish people."

"The international community must step up the struggle against antisemitism," he said.

Almog said there was "quite a bit" of people in the synagogue when the shooting started.

“It’s 100 percent that he knew that we have our Passover service over there," he said. "Every time in those services we bring our kids, and they play around together while we’re praying.”

CORRECTION: (April 30, 11:55 p.m. ET): An earlier version of this article misspelled the last name of the San Diego police chief. He is David Nisleit, not Nislei.

Dennis Romero reported from San Diego and Andrew Blankstein and Phil Helsel from Los Angeles.