A 36-year-old Baton Rouge man already serving nearly nine years in federal prison on an unrelated gun charge pleaded guilty Monday to the attempted first-degree murder of a police officer and was sentenced to 30 years in state prison.

Melvin Trosclair was scheduled to stand trial Monday in Baton Rouge state court in the Aug. 11, 2012, attempted killing of city police Officer Nicholas Collins on Winbourne Avenue.

Police have said Collins flagged down Trosclair after he saw him driving slowly. Trosclair pulled over but ran away. Collins chased Trosclair behind a house and tried to subdue him, but Trosclair got away and ran back to his car.

Trosclair pulled out a stolen gun and fired at the officer who was continuing to chase him.

Collins returned fire, hitting Trosclair in the shoulder.

State District Judge Richard Anderson ordered Trosclair to serve the 30-year prison term without benefit of parole, probation or suspension of sentence.

Four months before the officer-involved shooting, federal marshals found Trosclair — a convicted felon at the time — in possession of a loaded pistol and body armor when they went to his North 28th Street residence to arrest him on an outstanding warrant.

U.S. District Judge James Brady sentenced Trosclair last year to 105 months in federal prison on his conviction for possession of a firearm by a convicted felon.

State prosecutors said the 30-year sentence will run consecutively to the federal term.