Gov. Jerry Brown has signed into law a bill that allows Californians to rescue animals trapped in hot cars without fear of prosecution.

The bill signed on Saturday lets citizens smash car windows to set the pets free as long as there is no other way to rescue them.

That means rescuers can break into the car if the animal appears to be in peril, the car is locked and law enforcement is not arriving quickly enough.

The rescuer must stay at the scene until law enforcement responds to the situation.

The bill was introduced after a series of incidents in which dogs died after being left in closed cars on hot days.