A man is fighting for his life and two police officers have been hospitalised after violence erupted across western Sydney on Wednesday night.

The night of crime began at 8.40pm in Greenacre, when a riot squad sergeant opened fire on a suspected stolen Toyota SUV after its driver allegedly pinned the officer between two vehicles to evade arrest.

The officer, 39, was treated for lower leg injuries and taken to hospital in a stable condition.

Police tracked the driver to the backyard of a Ryde home one block from Victoria Road, where a 32-year-old man was suffering from gunshot wounds to his arm and shoulder.

He was two streets from the abandoned Toyota, which was found with three gunshots through its windscreen.

Paramedics treated the 32-year-old at the scene before he was taken to hospital in a stable condition.

In a separate incident on the same night, a person in a black utility fired several shots into another car at Campbell Hill Road, Chester Hill, about 11.30pm. Both cars fled the scene before police arrived.

About five minutes after the initial call about the shooting, police were notified a 26-year-old man had turned up at Auburn Hospital with severe gunshot wounds. The man remains in a critical condition on Thursday morning, and has been transferred to another hospital.

Police say officers discovered a Mercedes with several bullet holes parked outside the hospital and attempted to speak to the man but were met by his 30-year-old associate, who allegedly punched a chief inspector in the head multiple times in a violent confrontation.

The associate has been charged with assaulting a police officer and will appear at Burwood Local Court on Thursday. The inspector was treated for a laceration to his head at the hospital.

Detectives continue to investigate both shootings on Thursday morning.