Mackey said that Devaughndre Broussard — the man who confessed to killing Bailey and said Mackey helped — was angry with him for having sex with women in whom he also had an interest, and so implicated him in the shooting deaths.

Mackey’s testimony was an unexpected turn in the trial and came on the day jurors had been told to instead expect closing arguments in the trial that has lasted about two months.

Broussard, Mackey said, “roughed up” a girl he liked after she and Mackey had sex. Outside court, Mackey’s lawyer, Gary Sirbu, said jurors “will infer” that Broussard was motivated by anger and jealousy to lie that Mackey committed murders.

Broussard testified that Mackey acted as the getaway driver following the Aug. 2, 2007, shooting of Bailey and that Mackey helped in the shooting death of 31-year-old homeless man Odell Roberson on July 8, 2007. Broussard also said Mackey bragged about killing a third man, Michael Wills, on July 12, 2007. Bakery leader Yusuf Bey IV ordered all the killings, Broussard said.

But Mackey told the jury of seven men and five women that he had nothing to do with the deaths. Mackey and Bey IV, both 25, have pleaded not guilty to all charges. Closing arguments in the trial are now expected to begin Wednesday.

Mackey, wearing a light brown shirt and dark tie, took the stand about 10 a.m., telling jurors in a deep, gravely voice, “I want to tell my side of the story, so to speak.”

He described himself as “a nerd” who was fascinated with the bakery’s cash register but also said he hid a loaded sawed-off shotgun under his bed in his room at the bakery complex because he was paranoid after being shot on three separate occasions when he lived in San Francisco.

Under cross examination from prosecutor Melissa Krum, Mackey confirmed cell phone records showing he called Bey IV at 5:02 a.m. the morning of Bailey’s death, saying Bey IV asked to be awakened so he could pray. It was the only time Mackey said Bey IV made such a request.

But Mackey said he couldn’t remember anything about the content of additional calls between the two men over the next few hours, including two calls within minutes of Bailey’s shooting. Mackey also said he couldn’t remember anything about four calls he and Bey IV exchanged right around the time the 36-year-old Wills was shot as he walked to a corner store.

Mackey said was working at the bakery when Bailey and Wills were killed and was in his bedroom when Roberson was shot, and happened upon the Roberson shooting scene just as police arrived after deciding to walk to a nearby store to buy candy.

Mackey also refuted earlier testimony in which Broussard said Mackey drove by and sat outside Bailey’s apartment building near Lake Merritt seven hours before the journalist was shot. Broussard also said he, Mackey and Bey IV drove past the shooting scene on Alice and 14th streets the next morning.

In recorded interviews, Bey IV told both Oakland police and District Attorney’s Office investigators that he, Mackey and Broussard sat outside the journalist’s apartment hours before the shooting. Bey IV first denied the visit, but later changed his story when confronted with evidence from a police tracking device hidden on his car. Bey IV also said Mackey was with him when they drove past the scene the next morning.

But a 1968 U.S. Supreme Court ruling precludes prosecutor Melissa Krum from playing those recordings for the jury, a law professor said Tuesday.

“The basic idea is that the Constitution guarantees every criminal defendant a right to confront the witnesses against him, and the Supreme Court has said that right can be compromised if the prosecution introduces a statement taken outside of court from the other defendant,” said David Sklansky, a law professor at University of California, Berkeley’s Boalt Hall law school and chair of the Berkeley Center for Criminal Justice.

In this case, using Bey IV’s recorded statement to incriminate Mackey can’t be allowed because Mackey would have no opportunity to cross-examine Bey IV, because he, in turn, has a constitutional right not to testify at trial.

Broussard testified in March that Bey IV ordered him and Mackey to kill Bailey, 57, to stop the journalist from writing about the bakery in the Oakland Post. Broussard told jurors he killed Roberson with Mackey’s help and that Mackey and Bey IV bragged about killing Wills because they wanted to “get a white devil.”

In early testimony, Mackey said he bore no hatred toward white people and never heard Bey IV preach at the bakery about racial hatred.

Mackey said he went to work at the bakery after desperately seeking a way out of San Francisco in June 2007 after being shot for the third time.