In a situation where human life might be endangered by a fire, it is a mitzva for anyone who can put it out to do so as soon as possible, since danger to human life overrides Shabbat. Even if the danger is uncertain, it is still a mitzva to put out the fire. For example, if a fire breaks out in a large building, even if it seems that all the residents managed to get out, one must put out the fire as long as there is a possibility that someone may still be inside. Even if the odds are that anyone left inside has already died, since there is still a chance that a rescue is possible, everything must be done to put out the fire (SA 329:3; below 27:1).
Everything necessary must be done as efficiently as possible on all fronts: Those able to rescue people from the fire should try to do so, and those able to extinguish or control the fire should try to do so with whatever means are at their disposal. At the same time, others should call the fire department. If an observer is uncertain whether the fire department has been called already, even if it seems likely that they have been, he too must call to make sure that they come, because the possibility of saving lives overrides Shabbat. At such a time one must not ask a rabbi what to do, but rather move as quickly as possible to help.
In practice, nowadays we treat any large fire that breaks out in a residential building as a life-threatening one that must be extinguished even on Shabbat. For example, if a fire breaks out in an apartment building, there is a concern that it may spread to additional apartments and there may not be time to evacuate the residents. Besides, when there is a large fire there is no time to check if there are apartments with babies or disabled people who cannot make their way out on their own. Additionally, some homes contain explosive gas canisters that endanger people outside the building, especially considering that fires often attract large numbers of gawkers. Sometimes it takes longer to clear people out of the area than to put out the fire. If the fire is near other homes, it might spread and endanger those residents. Sometimes a fire breaks out in a storage area containing chemicals whose poisonous fumes may endanger area residents.
R. Shlomo Goren ruled that if anti-Israel terrorists start a fire that will damage property, it may be extinguished on Shabbat even if there is no danger to life, because if we do not put it out, the terrorists will feel they have succeeded and will be motivated to undertake similar attacks that could endanger lives (this is based on SA 329:6 and R. Goren’s expansion of the category of a “border town,” which may be defended against even property damage on Shabbat, to all cities in Israel, where low-grade conflict can break out; see below 27:12).