PORTLAND — A Portland man with a history of mental illness has been sentenced to 32 years in prison for stabbing an acquaintance and trying to cut up the body.

Under an agreement with prosecutors, Shawn Garland pleaded guilty to murder in November in the killing of 58-year-old Richard Meyers in Garland’s apartment. Prosecutors say Garland stabbed Meyers 97 times on Aug. 12, 2010, before trying to dismember his body to hide the remains.

The Portland Press Herald said the plea agreement called for a prison sentence of no more than 35 years.

After Tuesday’s sentencing, Garland’s attorney said he counseled against the plea agreement, saying he planned to use an insanity defense at trial based on Garland’s mental illness.