A woman kisses her son during a prayer service held to honor the shooting victims at North Park Elementary School, Monday, April 10, 2017, in San Bernardino, Calif. A man walked into his estranged wife's elementary school classroom in San Bernardino and opened deadly fire on Monday. (AP Photo/Jae C. Hong)
A woman kisses her son during a prayer service held to honor the shooting victims at North Park Elementary School, Monday, April 10, 2017, in San Bernardino, Calif. A man walked into his estranged wife's elementary school classroom in San Bernardino and opened deadly fire on Monday. (AP Photo/Jae C. Hong) Credit: Jae C. Hong

SAN BERNARDINO, Calif. — The man who opened fire in a San Bernardino school was a pastor and Navy veteran who accused his newlywed wife of infidelity. When he failed in his efforts to win her back, he went to her classroom and fatally shot her and one of the special needs children she taught, police said Tuesday.

In the weeks before Monday’s violence Karen Smith told family members her new husband, Cedric Anderson, had tried to get her to return home and threatened her, San Bernardino Police Chief Jarrod Burguan said. She didn’t take him seriously and thought he was just seeking attention, he said.

Police do not know what triggered the attack or why Anderson chose to attack Smith at the school, Burguan said, adding she never shared any information about her marital problems with colleagues.

On Monday morning, hundreds of panicked parents descended on the North Park School in San Bernardino, waiting for hours for information on their children in a city that is still on edge 16 months after a terror attack that killed 14 people and wounded 22 others at a meeting of county employees.

Anderson, 53, walked into the special-education classroom Monday and fired off 10 shots with a .357 Magnum, targeting his wife but also hitting two of her students before turning the gun on himself. Eight-year-old Jonathan Martinez, who suffered from a genetic condition known as Williams Syndrome and had survived heart surgery, was killed. A 9-year-old boy was also shot but was in stable condition and in good spirits, watching cartoons in his hospital bed Tuesday morning, police said.

Anderson and Smith had married in late January but separated in mid-March after Anderson accused her of infidelity, prompting Smith to move out, Burguan said.

Just weeks before the shooting, Anderson had professed his love to Smith in a series of social media posts, including one that called her an “angel.”

Smith’s mother, Irma Sykes, said her daughter had been friends with Anderson for about four years before they got married.

“She thought she had a wonderful husband, but she found out he was not wonderful at all,” Sykes told the Los Angeles Times.

“She left him and that’s where the trouble began,” Sykes said. “She broke up with him and he came out with a different personality. She decided she needed to leave him.”

Anderson, a self-proclaimed pastor whose Facebook profile is filled with Bible quotes and religious references, had been unemployed but previously held jobs as a maintenance worker, police said. He had joined the Navy in 1982 and re-enlisted as a reservist from 1987 until 2003, working as a builder, according to military records.

Anderson had been arrested four times since 1982, though had no convictions, Burguan said. Those arrests included one in August 2012 on suspicion of spousal battery, and in May 2013 on suspicion of brandishing a knife, said Torrance Police Sgt. Ronald Harris.