One of three men accused of beating and kicking a Portland man to death in his Cumberland Avenue apartment pleaded guilty Thursday to manslaughter as part of a plea deal to have the more serious charge of murder dismissed.

Abil Teshome, 24, of Portland, accepted the plea deal which caps his maximum prison sentence at 20 years, just two weeks before he was scheduled to stand trial in the Cumberland County Courthouse in Portland for the death of 49-year-old Freddy Akoa on Aug. 9, 2015.

Teshome and one other defendant, Mohamud Mohamed, were to be tried together, with jury selection set for July 8 and the trial to follow on July 11.

With Teshome’s plea before Justice Thomas Warren on Thursday, it appears unlikely that Mohamed, 37, of Portland, will stand trial alone on those dates. Mohamed’s lead attorney, Peter Cyr, was not available for comment Thursday.

The third defendant, Osman Sheikh, 32, of Portland, who police say played a lesser role in Akoa’s death, will be tried separately, according to court records.

Teshome stood in court flanked by his attorneys, Alison Thompson and Jon Gale, during a brief hearing before the judge accepted his plea. Teshome, dressed in an orange jail uniform, mostly stared at the desk in front of him between the judge’s questions, but looked up each time as he answered Warren.

Teshome was born in Ethiopia and came to the U.S. as a teenager, but speaks fluent English. He is not a U.S. citizen.

“It is certainly possible that Mr. Teshome will face adverse immigration consequences as a result of this plea,” Gale explained to the judge. Consequences could range from deportation to being denied U.S. citizenship. Gale said the immigration consequences for a manslaughter conviction are typically less than for a murder conviction.

Assistant Attorney General John Alsop outlined the case the state would have made against Teshome, including his confession to police days after Akoa’s death and the fact that Akoa’s blood was found on Teshome’s shirt.

Alsop said the plea deal sets Teshome’s base sentence at 30 years. The state will argue that Teshome should serve 20 years of that sentence in prison with the remaining 10 years suspended as leverage during a four-year probation term. Under terms of the plea deal, Teshome’s attorneys may argue that more than 10 years should be suspended.

The murder charge against Teshome will be dismissed when he is sentenced. Murder is punishable by 25 years to life in prison.

Warren did not immediately set a sentencing date, but said that it would likely be at the end of August or beginning of September.

Mohamed’s case was also on a court docket list Thursday for a settlement conference before a different judge, Justice Paul Fritzsche, behind closed doors. Alsop declined to comment on what happened at that hearing.

The three suspects are accused of beating, kicking and bashing Akoa in the head with furniture on the night of Aug. 9 in an assault that involved alcohol and lasted for hours in his apartment, according to an affidavit filed by Portland police Detective Christopher Giesecke.

Akoa had 39 rib fractures from the attack, cuts and bruises all over his head and torso, and a lacerated liver when his accused killers left him on his living room floor in Apartment 18 at 457 Cumberland Ave. the next morning.

The men were seen in surveillance footage entering the apartment building with Akoa and a woman at 4:40 p.m. on Aug. 9. Police learned of Akoa’s death two days later when his mother became concerned that she couldn’t reach her son and asked the building management to check on him, according to the affidavit.

Police found Teshome, Mohamed and Sheikh in Deering Oaks park on the morning of Aug. 13, 2015, and arrested Teshome on a charge of criminal trespassing.

“Teshome said he lost control of himself and started hitting Akoa several times in the head. Teshome admitted to punching and kicking Akoa multiple times and knocking him to the ground. Teshome also stated that he also struck Akoa with his hands and feet while Akoa was lying on the ground,” Giesecke wrote.

Teshome also allegedly confessed that he used a board from a makeshift coffee table to beat Akoa over the head and to strike his foot, the affidavit says.

“(Teshome) said that he and Sheikh left Akoa’s apartment around the same time and that he believed Akoa was alive when he left,” Giesecke wrote.

Video surveillance footage from the apartment building shows the woman and Mohamed leaving the building at 5:38 a.m. on Aug. 10, 2015, but Teshome and Sheikh cannot be seen in the footage, the affidavit says.