A murder trial in Portland came to an unusual end on Friday when a New York man accused of fatally stabbing a Westbrook man in 2011 flip-flopped multiple times before pleading guilty to a lesser manslaughter charge late in the afternoon.

Tareek Hendricks, 32, spent much of the fourth day of his trial in the Cumberland County Courthouse in consultation with his lawyers, agreeing once in the morning to a plea deal, only to back out at the last minute.

Hendricks had gone so far as to say the word “guilty” twice in the morning, when asked by Superior Court Justice Thomas Warren how he would plead in a deal offered to him.

Hendricks offered no explanation why he changed his mind again and withdrew his guilty plea to charges of manslaughter for stabbing Robert Stubbs to death and aggravated assault for injuring Stubbs’ wife, Melissa, with the same knife.

The plea deal offered by Deputy Attorney General Lisa Marchese capped his prison sentence at no more than 17 years for manslaughter and allowed him to serve whatever sentence the judge decided on the assault charge, up to the maximum of 10 years, at the same time as the manslaughter sentence. The plea offer allows Hendricks’ attorneys to argue for a lesser prison term.

The trial resumed briefly in the afternoon, with Marchese calling two witnesses to testify, but the courtroom proceeding came to a halt again around 2 p.m. as attorneys began whispering at the edge of the judge’s bench out of earshot of the jurors.

Warren called for a recess around 2:15 p.m., allowing jurors to leave the courtroom, but never called them back in because Hendricks changed his mind again after talking with his attorneys for more than an hour.

Shortly after 4 p.m., Hendricks uttered the words “guilty” again and stuck to his decision after the judge asked him repeatedly if he was sure.

“At this point, you still want to go forward with the plea?” Warren asked from the bench.

“Yes, sir,” Hendricks replied, standing between his attorneys, Jon Gale and Amy Fairfield.

The judge later asked the defense attorneys whether they thought the plea deal was in Hendricks’ best interest.

“Absolutely not,” Fairfield replied, shaking her head.

“We have counseled against him accepting this plea offer, and he understands,” Gale said.

Hendricks faced life in prison if convicted of murdering Robert Stubbs by stabbing him eight times in the torso, back and thigh during a fight on April 21, 2011, at the Stubbses’ home at 73 Central St. in Westbrook.

Marchese had initially withdrawn her plea offer in the morning after Hendricks’ first flip-flop, but re-extended it in the afternoon after both she and the judge heard from Hendricks.

“I came to understand that he really wanted to plead guilty and his lawyers didn’t want him to plead guilty,” Marchese said after court adjourned for the day. “I think it is an appropriate resolution. I think Bobby Stubbs is a victim, but it is difficult to predict how a jury would have viewed him because he hit Tareek Hendricks with a bat first and he clearly was a drug user.”

The fight started in the kitchen when Robert Stubbs, who was high on crack cocaine, escalated an argument by hitting Hendricks, his drug dealer, with a baseball bat. Details about what happened and whether the Stubbses told Hendricks to leave their home before the fight were unclear from witness testimony.

Hendricks was accused of stabbing Melissa Stubbs after she intervened and struck Hendricks repeatedly with a kitchen chair.

Melissa Stubbs testified during the first three days of the trial, saying that both she and her husband told Hendricks to leave the house before the fight started. She admitted under cross-examination that she had not told police in earlier statements when or if they told Hendricks to leave before the fight began.

Marchese said in her opening statement that Hendricks could have left without stabbing either Robert or Melissa Stubbs and that Robert Stubbs was within his legal rights to use a bat to get Hendricks out once he had been told to leave.

Hendricks’ attorneys argued that he acted in self-defense.

The Stubbses locked Hendricks out of their house after the stabbing and shortly before Robert Stubbs died. Neighbors testified they saw a man banging on the door of the Stubbses’ house after a commotion, demanding his belongings.

Hendricks left before police arrived and was sought for more than a year before he was arrested in Syracuse, New York, on July 11, 2012. He has remained in custody since then.

His sentencing date has not been set.