SAN DIEGO — All northbound lanes of Interstate 805 near Imperial Avenue reopened Monday afternoon after a shooting involving a California Highway Patrol officer prompted a lengthy closure.

The closure began around 8 a.m., when drivers were detoured to the Imperial Avenue off-ramp, according to Caltrans.

Around 7:48 a.m., a CHP officer was conducting a traffic stop on the right shoulder of northbound I-805 at Imperial Avenue, Sgt. Brian Pennings said at a news conference. While the officer was walking back to his patrol car, he saw that a man had pulled a vehicle up behind him.

“The officer made contact with this individual while he was still seated inside of his car,” Pennings said. “The officer observed immediately that he was brandishing a weapon, which was a knife.”

The officer retreated to his patrol car and took cover behind it. The suspect got out of his car, brandishing the knife, and advanced toward the officer, Pennings said.

“Despite numerous verbal commands to the suspect, the suspect failed to stop, failed to drop the weapon and continued to charge towards the officer,” Pennings said. “This resulted in the officer unfortunately having to use his weapon to stop forward progress.”

The suspect was taken into custody, and paramedics took him to a hospital to be treated for non-life threatening injuries.

The CHP officer, who is a five-year veteran of the agency, was not injured, Pennings said.

The reason why the driver pulled up behind the CHP officer’s vehicle was still under investigation, Pennings said.

Traffic on northbound I-805 was backed up past state Route 54 due to the closure, causing heavy delays for morning commuters.

By 1:30 p.m., all lanes had reopened, Caltrans said.