An Elmira man injured in a shootout with police last July has pleaded guilty to several felonies.

Wilfredo D. Maisonet, 28, pleaded guilty this week in Chemung County Court to two counts of first-degree attempted aggravated manslaughter and one count of second-degree criminal possession of a weapon.

The charges resulted from a July 2, 2017 incident in which Maisonet reportedly fired several shots from a 9-millimeter pistol into the home of an ex-girlfriend at 240 Allen St. in the Town of Southport.

While leaving the scene, Maisonet fired several more times at two Elmira police officers who responded to the incident.

Maisonet then hid in a densely wooded area nearby for several hours. When police closed in to apprehend him, he still possessed the firearm and was shot by responding officers, police said.

The Chemung County Sheriff's Office, New York State Police and West Elmira Police Department assisted at the scene.

Maisonet was initially indicted by a grand jury on two charges of first-degree attempted murder, two counts of attempted aggravated assault on a police officer, two counts of second-degree criminal possession of a weapon and one count of first-degree reckless endangerment, all felonies.

Maisonet was also wanted on a parole violation at the time of his arrest. He was previously convicted in 2011 for criminal possession of a weapon, and was released on parole only four months before the July 2017 incident.

Under the terms of the plea agreement, he will be sentenced to 15-year determinate prison terms on each attempted manslaughter count, to run consecutively, for an aggregate sentence of 30 years, plus five years post-release supervision.

On the weapons count, Maisonet will receive a determinate 10-year prison term that will run consecutive to one of the manslaughter counts.

As part of his plea, Maisonet was required to waive his right to appeal.