Water supply and sanitation in Gibraltar have been major concerns for its inhabitants throughout its history, from medieval times to the present day. The climate of Gibraltar is a mild Mediterranean one with warm dry summers and cool wet winters. Since daily records of rainfall began in 1790, annual rainfall has averaged a mean of with the highest volumes in December and the lowest in July.Rose (2001), p. 112 However, most of Gibraltar's small land area is occupied by the Rock of Gibraltar, a limestone outcrop that is riddled with caves and crevices.Sawchuk, p. 131 There are no rivers, streams, or large bodies of water on the peninsula, which is connected to Spain via a narrow sandy isthmus.

Gibraltar's water supply was formerly provided by a combination of an aqueduct, wells, and the use of cisterns, barrels and earthenware pots to capture rainwater. This became increasingly inadequate as Gibraltar's population grew in the 18th and 19th centuries; the settlement was a breeding ground for lethal diseases such as cholera and yellow fever, which killed thousands of its inhabitants and members of the British garrison in repeated outbreaks. In the late 19th century, a Sanitary Commission instigated major improvements which saw the introduction of large-scale desalination and the use of giant water catchments covering over 2.5 million square feet (nearly 250,000 m2). Today Gibraltar's supply of drinking water comes entirely from desalination, with a separate supply of saltwater for sanitary purposes—both supplies are delivered from huge underground reservoirs excavated under the Rock of Gibraltar.

Under Moorish and Spanish rule

Gibraltar was uninhabited during ancient times due in part to a lack of easily accessible water to support a permanent population,Jackson, p. 22 but in the 11th century the Moors established a fortified stronghold there in response to military threats from the Christian kingdoms of Aragon and Castile.Hills, p. 13 The Moors obtained water through roof catchment of rainfall, shallow wells in the Quaternary sands to the west of the Rock of Gibraltar, and storing local surface runoff in cisterns.Rose (2000), p. 248 In the 14th century they constructed an aqueduct that collected water from the Red Sands, an area south of the town in the vicinity of what is now the Gibraltar Botanic Gardens, and transported it some to a fountain within the town.Sawchuk, p. 134 Fountain Ramp, on the western side of John Mackintosh Square, preserves in its name the location of the aqueduct's original terminus.Rose (2004), p. 244

After the Crown of Castile conquered Gibraltar in the 15th century, the aqueduct was renovated and a pair of reservoirs was constructed around 1694. A medieval reservoir, Nun's Well, still survives at Europa Point in the far south of Gibraltar, though it is unclear who built it and when. In the 1770s, Thomas James recorded that it was infested with leeches. This caused problems for the soldiers who had to drink the water, as the leeches attached themselves to the soldiers' tongues "and sucking for sustenance, caused the discharge of blood, which ... frightened some of the men not a little."James, p. 327

The only other source of freshwater was from wells bored into the isthmus with Spain, which produced non-potable water. During the 19th century, the public could draw water for a fee but this supply was taxed by the British. A few dwellings, mainly those occupied by British officials, had their own private wells. However, most of the population had to rely on the public wells, from where they drew water which they carried back into the town. The water level gradually receded during the dry summer months, and sometimes it dried up altogether if precipitation during the year had been lower than usual.Sawchuk, p. 135

Historical sources conflict on exactly how much groundwater was available in Gibraltar. A 17th-century Spanish writer, Alonso Hernández del Portillo, asserts that "the city contained many tides and fountains of very sweet and healthy water" and that "fountains of fresh water could be seen spouting out of the sea near the foot of the Rock", possibly referring to a spring at a fault called the Orillon (at the site of the later Orillon Batteries) in the north-west face of the Rock. By the mid-19th century, however, the British writer Frederick Sayer was reporting that "there are no springs of pure fresh water"; the supplies from the few shallow wells that did exist would have been brackish at best. What is certain, however, is that by Sayer's time the existing water supplies were increasingly inadequate as Gibraltar's civilian population increased rapidly.Rose (2000), p. 250

Under British rule

The Spanish water infrastructure continued to be used by the British well after the capture of Gibraltar in 1704. As late as 1863, there was not a single water pipe in the town apart from the Spanish aqueduct.Rose (2000), p. 249 The main source of drinking water, other than the aqueduct, was rainwater that had been collected during the winter. The British military relied on large cisterns mounted on the roofs of buildings to gather rainwater, while ordinary Gibraltarians used barrels and large earthenware pots called tinajas. At the time, most Gibraltarians lived in two- or three-storey buildings with an interior courtyard, called patios, which were occupied by two or three families. They were generally owned either by absentee landlords or the British government, neither of which had much interest in building private cisterns. The courtyards of the patios were thus crowded with barrels and tinajas which supplied the occupants' water during the summer drought. If they ran out, the only other source of water was from pedlars who brought barrels of water in from Spain, charging high prices for the privilege. This encouraged many people to recycle their water as much as possible, reusing the same water for different purposes.Sawchuk, p. 136

Gibraltar's chronic shortage of water had significant negative consequences for all the inhabitants, civilian and military alike. The military took priority but made no effort to ration or apportion it. The British Army and the Royal Navy effectively competed for the same limited supply. Both required large volumes of water, but the arrival of a fleet could result in Gibraltar's supplies of water and food being consumed suddenly with no provision left over for others who might need it. The rapid growth of Gibraltar's population during the 18th and 19th centuries added to the pressure on the territory's water supply. There was a fivefold increase in numbers between 1784 and 1800, with a further tripling to 16,800 inhabitants by 1814. The old Spanish water supply and rainwater catchments in the town had been manageable for a combined military and civilian population of up to about 3,000 people, but above that level the impact of water shortages became increasingly severe.Rose (2004), p. 246

The most serious impact was, perhaps not surprisingly, on the state of public health in the territory. The large numbers of water containers standing open across Gibraltar provided an ideal breeding habitat for mosquitoes. Ships carrying cargoes from Africa brought with them the tropical disease yellow fever, which is spread by female mosquitoes carrying the infection. From 1804, Gibraltar suffered five outbreaks of yellow fever; in the first and most devastating, the death toll amounted to 5,733 people out of a total of around 18,000, representing 32 per cent of the population.

The second epidemic coincided with the arrival in 1814 of General Sir George Don as the new Governor of Gibraltar. He ordered that all new buildings were to have a cistern, and instructed that existing cisterns were to be covered. The latter measure would have helped somewhat with the mosquito problem though this could not have been Don's intention, as the relationship between mosquitoes and yellow fever was not yet known – the outbreaks of the disease had been blamed on "miasma" or foul air emanating from the piles of rotting refuse that could be found all over Gibraltar.Sawchuk, p. 137

A new sewage system was built on Don's orders in 1815, but this was so poorly designed that it actually worsened Gibraltar's sanitary problems. It had no ability to be flushed and was insufficiently inclined to keep the sewage flowing out to the bay. As a result, the system merely brought sewage down from the upper part of the town to the lower part, where it piled up under the main streets. The sewage remained there until the winter rains dislodged it and flushed it into the bay. Because the outfalls were so short, however, the sewage simply washed back up onto the shoreline and resulted in the seafront being coated in a slick of effluent.

Apart from mosquitoes, Gibraltar's cisterns had other major hygiene problems. The water they stored was unfiltered and they were often located alongside functional areas such as kitchens, privies and areas for animals such as poultry. Gibraltar's colony of Barbary macaques added to the problem by fouling the rooftops and cisterns. The water was notionally fresh but in reality the cisterns tended to accumulate unhygienic debris of various types.Sawchuk, p. 138

The outbreak of the Asiatic Cholera Pandemic reached London by 1831 and Gibraltar by 1832. As with yellow fever, it was attributed to "miasma" and its true cause – contaminated water – was unknown. Gibraltar's garrison was far more badly affected than the civilian population, suffering three times the mortality rate. Even so, the number of deaths was relatively moderate and the British authorities felt little pressure to do anything about the situation despite further outbreaks of cholera in 1848–49 and 1854.

By the mid-19th century, however, reformers in Britain were coming to appreciate the link between sanitation and public health. The discovery by the London doctor John Snow of the link between cholera and sewage-contaminated water led to improvements in water supplies in many British towns and cities. At the same time, the military establishment came to better appreciate the importance of soldiers' living conditions after the experiences of the Crimean War, in which far more died of disease than in battle. This led to improvements being made in the sanitary conditions of the barracks of Gibraltar, through providing better washing facilities and drainage. It also became apparent that Gibraltar's water supplies would be inadequate in the event of another prolonged siege.Sawchuk, p. 139

A Parliamentary Commission on Barrack and Hospital Improvements was established in 1862 to inquire into the sanitary conditions in Gibraltar and other British Mediterranean possessions. Its conclusions were scathing; there had been no investment in the public water infrastructure in Gibraltar for 150 years, forcing the civilian population to rely entirely on their own resources and ingenuity. The public water storage facilities provided only four to six litres of water per person per day, for all purposes including washing, cooking and drinking – well below the recommended level of nine litres per day. A third of the population did not have access to cisterns or private wells and had to either draw their water from the brackish wells on the isthmus or buy it at exorbitant prices from Spanish water pedlars. One day's supply of six litres of imported water cost as much as a year's supply of water in England. The military, too, was undersupplied, with only seven litres per day for each member of the garrison.