Leonardo da Vinci designed a sprinkler system in the 15th century. Leonardo automated his patron's kitchen with a super-oven and a system of conveyor belts. In a comedy of errors, everything went wrong during a huge banquet, and a fire broke out. "The sprinkler system worked all too well, causing a flood that washed away all the food and a good part of the kitchen."
Ambrose Godfrey created the first successful automated sprinkler system in 1723. He used gunpowder to release a tank of extinguishing fluid.
The world's first modern recognizable sprinkler system was installed in the Theatre Royal, Drury Lane in the United Kingdom in 1812 by its architect, William Congreve, and was covered by patent No. 3606 dated the same year. The apparatus consisted of a cylindrical airtight reservoir of 400 hogsheads (c. 95,000 litres) fed by a  water main which branched to all parts of the theatre. A series of smaller pipes fed from the distribution pipe were pierced with a series of  holes which would pour water in the event of a fire.
Frederick Grinnell improved Henry S. Parmalee's design and in 1881 patented the automatic sprinkler that bears his name. He continued to improve the device and in 1890 invented the glass disc sprinkler, essentially the same as that in use today.
"Until the 1940s, sprinklers were installed almost exclusively for the protection of commercial buildings, whose owners were generally able to recoup their expenses with savings in insurance costs. Over the years, fire sprinklers have become mandatory safety equipment" in some parts of North America, in certain occupancies, including, but not limited to newly constructed "hospitals, schools, hotels and other public buildings", subject to the local building codes and enforcement. However, outside of the US and Canada, sprinklers have rarely been mandated by building codes for normal hazard occupancies which do not have large numbers of occupants (e.g. factories, process lines, retail outlets, petrol stations, etc.)
Sprinklers are now commonly installed in non-industrial buildings, including schools and residential premises. This is largely as a result of lobbying by the National Fire Sprinkler Network, the European Fire Sprinkler Network, and the British Automatic Fire Sprinkler Association.