ELIZABETH — An Essex County man with an extensive criminal history has been sentenced to 18 years in state prison for leading police in two Union County towns on a prolonged pursuit before being caught with heroin in 2012, acting Union County Prosecutor Grace Park announced.

Shareef Mayfield of Orange must serve at least 96 months of that sentence, or eight years, before the possibility of parole, according to terms set by state Superior Court Judge Joseph Donohue.

The date was January 18, 2012 when Hillside police officers pulled over a Chrysler Sebring for a minor traffic infraction, according to Union County Assistant Prosecutors Jill O’Malley and Travis Carter, who prosecuted the case. When the officers approached the vehicle and attempted to speak with the driver, who was later identified as the 33-year-old Mayfield, he sped off, nearly knocking one of them over.

Mayfield then led officers on an approximately two-mile pursuit from Hillside into Union at high speeds, O’Malley and Carter said. Mayfield ultimately crashed the Sebring, which belonged to his then-girlfriend, on Vauxhall Road in Union, then ran from the scene.

Mayfield subsequently led the officers on a brief foot pursuit, crossing all 10 lanes of the Garden State Parkway before heading into a residential area, where he was finally apprehended and found to be in possession of eight bags of heroin.

Mayfield was subjected to an extended prison term due to a criminal history that includes 17 prior felony convictions, mostly on drug-related offenses. Donohue noted that Mayfield had even been arrested several times while free on bail set for the offenses he was sentenced for on Friday.

A Union County jury deliberated for 45 minutes last month before returning guilty verdicts against Mayfield, who been charged with second-degree eluding police, third-degree possession of a controlled dangerous substance, and fourth-degree obstruction of justice.

Donohue additionally sentenced Mayfield to five years on the drug charge, with that term to run concurrently with the 18-year term.