A man who said he was pursuing "jihad" pleaded guilty to murder and terrorism in New Jersey on Tuesday and surprised prosecutors by admitting in court that he also killed three people in Washington state in 2014.

The man, Ali Muhammad Brown, 34, formerly of Seattle, changed his mind and pleaded guilty to having killed Brendan Tevlin, 19, of West Orange, New Jersey, as jury selection was under way in Essex County Superior County, the county prosecutor's office said. Then, without prompting, he admitted to having killed three other men in Washington — two of whom he said he killed because he believed they were gay.

"In his statement to the court today Brown admitted that the killings were a part of what he described as a 'jihad,'" said the prosecutor's office. He faces a mandatory sentence of life in prison.

Ali Muhammad Brown in court in Newark, New Jersey, in on January 2106. Patti Sapone / Pool/NJ Advance Media via AP file

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Brown had already been charged with the three deaths in the Seattle area — a man who was shot in the Seattle suburb of Skyway in April 2014 and two men who were shot outside a Seattle nightclub two months later. Essex County prosecutors said Brown admitted to having killed the two men in June 2014 "because he believed they were homosexual."

King County, Washington, prosecutors said at the time that all of the killings showed "an extreme level of violence." If he's ever convicted of those killings, he could face the death penalty.

Prosecutors said Tuesday that the guilty plea in the New Jersey case took them by surprise because they had refused to agree to a plea bargain, meaning Brown made the admission knowing he would get no reduction in sentence.

"We did not negotiate with this defendant," Acting County Prosecutor Robert D. Laurino said. "From the beginning, our position has been that he had to plead to all the charges or we would go to trial and let the jury decide."

In addition to Tevlin's murder, Brown pleaded guilty to first-degree terrorism, first-degree carjacking, first-degree robbery, unlawful possession of a handgun and possession of a weapon for an unlawful purpose.

Brown, who's already serving 35 years in the New Jersey State Prison for armed robbery, is scheduled for sentencing May 1 in what state officials said was the first murder case ever to have been brought under New Jersey's terrorism statute.

"He grievously harmed families and terrorized entire communities across the country," said Assistant Essex County Prosecutor Jamel Semper, who led the prosecution. "This defendant is no martyr. He's just an admitted terrorist who will now spend the rest of his life in prison."

Prosecutors confirmed that Brown is the same Ali Muhammad Brown who was convicted in federal court in Washington in 2005 of conspiracy to commit bank fraud in connection with a plot to bilk several banks from 2002 to 2004.

NBC News reported in 2004 that he was among at least 13 Seattle-area residents who were accused of pursuing the fraud scheme as part of a wide-ranging plot to illegally import people from the West African nation of Gambia into the United States.