A man and a San Bernardino County Sheriff's Department deputy were sent to the hospital Saturday night after a shooting in Rancho Cucamonga, authorities told FOX 11.

Deputies say they were searching a car near the intersection of Rochester Avenue and Foothill Boulevard around 7:15 p.m. when another car came and rammed the car and the deputy, pinning the deputy between the two cars.

The driver then got out of the car and allegedly approached the deputy while holding a knife. That is when the suspect was shot.

The suspect was taken to the hospital in unknown condition.

RETRIEVER MIX IN CALIFORNIA RESCUED AFTER LEG INJURY IS LOOKING FOR A FOREVER HOME

Aerials of Rancho Cucamonga deputy-involved shooting

Aerials of the scene where deputies shot a man who went after a deputy with a knife after allegedly pinning him between two cars. (FOX 11 Los Angeles)

The deputy who was pinned between the cars was sent to the hospital with injuries to his legs. Officials said they were not sure if the deputy suffered any other injuries as a result of the incident. 

CALIFORNIA MAN CHARGED AFTER VIDEO FOOTAGE SHOWS HIM STEALING DOG THROUGH WINDOW OF PARKED CAR

San Bernardino Sheriff's Department deputy-involved shooting

Close up aerial view of deputy-involved shooting scene in Rancho Cucamonga, Calif. Sept. 24, 2022. (FOX 11 Los Angeles)

CLICK HERE TO GET THE FOX NEWS APP

The sheriff's department did not say what the original search of the vehicle was for or if the vehicle was related to the man who allegedly rammed the deputy. 

The investigation is still ongoing.