A 35-year-old man has been sentenced to a 40-year term for stabbing his ex-girlfriend to death in a Shakopee apartment the two once shared.

Fraider Diaz-Carbajal, whose criminal history led to his deportation to Mexico several years ago, was sentenced Friday in Scott County District Court after pleading guilty to second-degree murder in connection with the Aug. 12 attack that killed Enedelia Perez Garcia, 27.

The term handed down by Judge Colleen King is the maximum allowed by law. With credit for time in jail since his arrest, Diaz-Carbajal will serve roughly the first 26½ years in prison and the balance on supervised release.

Garcia died from multiple stab wounds all over her body, according to police. A 7-year-old daughter is among her survivors.

The attack occurred when Garcia came to the apartment to retrieve some belongings after moving out “due to the domestic abuse,” court records revealed.

A resident in the building told police that she saw Diaz-Carbajal slash his own throat and stab himself in the abdomen.

U.S. Immigration and Customs Enforcement (ICE) said Diaz-Carbajal has three drunken-driving convictions on his record and another conviction for domestic assault against Garcia.

A federal immigration judge in December 2012 ordered him deported to Mexico, and ICE officers carried out that order two days later. The agency said he illegally re-entered the United States before the fatal stabbing occurred.