An officer was shot in the leg Friday after he pulled over a known drug dealer driving on a suspended license, the police commissioner said.

The injured officer boxed in the suspect's vehicle on a side street in the city's Dorchester neighborhood at about 10:30 a.m., knowing that the suspect was on probation after being released from prison in April, police Commissioner William Evans said.

The suspect got out of his vehicle and opened fire in an "unprovoked" attack before running away, Evans said. The officer returned fire. The suspect was caught and tackled by other officers after a short foot pursuit. Police also recovered a gun they think was used in the shooting.

The suspect was identified as 27-year-old Grant Headley. He will likely be arraigned Monday, a spokesman for the Suffolk district attorney's office said. Headley was on probation following his release from a five-year state prison term on a 2009 arrest on gun and drug charges, prosecutors said.

The prosecutor's office said it didn't know whether Headley had an attorney.

The pursuing officers showed "incredible restraint" in not opening fire on the fleeing man, Mayor Marty Walsh said.

The injured officer used a department-issued tourniquet to help stanch the blood flow from his wound.

"The leg was bleeding pretty good," Evans said.

Tourniquets became standard issue just a few months ago, and officers had requested them after the 2013 Boston Marathon bombing, union president Patrick Rose said.

The injured officer was taken to Boston Medical Center, where he was met by his wife. His name was not released. He has been on the force for nine years and is a member of the drug unit.

"I'm grateful we're not here under a worse situation," Walsh said.