Four armed bank robbers opened fire on police on crowded streets in Pleasanton, disabling a patrol cruiser before carjacking another vehicle and vanishing, officials said Friday.

The dramatic episode unfolded around 10:40 a.m., when police got a call about an armed robbery at the Wells Fargo Bank at 4967 Hopyard Road, said Shannon Whitaker, a Pleasanton police spokeswoman.

Officers caught up to the robbers as they fled west on Inglewood Drive near Hopyard in a white GMC Yukon, Whitaker said. A person in the fleeing vehicle opened fire on police, hitting the front window and hood of the pursuing vehicle with rifle rounds, officials said.

The patrol cruiser was disabled, and the Yukon sped off, police said. The robbers then carjacked the driver of a brown Honda CRV at Muirwood Drive and Springdale Avenue and abandoned the GMC, officials said.

Pleasanton police shut down city streets as they investigated the incident and searched for the robbers, who were all wearing black hoodies, Whitaker said.

An officer was treated for minor injuries and was released from the hospital.

Police were searching for the brown CRV with license plate 5USY995. It was last spotted on Muirwood Drive.

The suspects are considered armed and dangerous and anyone with information can call Pleasanton police at 925-931-5100.

Evan Sernoffsky is a San Francisco Chronicle staff writer. Email: esernoffsky@sfchronicle.com Twitter: @EvanSernoffsky