Map from Google - Gibraltar

The climate of Gibraltar, small british territory in southern Spain, is Mediterranean, with mild and rainy winters, and warm and sunny summers, but it has a peculiar microclimate, wet and windy, and is protected from both cold and heat waves, because of its location on the strait of the same name and the presence of the Rock, a promontory overlooking the city, 426 metres high.
Here are the average temperatures.
Average temperatures - Gibraltar
GibraltarJanFebMarAprMayJunJulAugSepOctNovDec
GibraltarJFMAMJJASOND
Min (°C)111112131517202020161312
Max (°C)161617182124272726211816

Precipitation amounts to nearly 800 millimetres per year, and follows a Mediterranean pattern, that is, more abundant from November to March, when it's equal to or greater than 100 mm per month (and in some years can be abundant), and very rare in summer.
Here is the average precipitation.
Average precipitation - Gibraltar
GibraltarJanFebMarAprMayJunJulAugSepOctNovDecYear
GibraltarJFMAMJJASONDY
Prec. (mm)120100100603010002070140130780
Days121010108312612111499

The wind blows frequently: in the cold half of the year it blows from the west, along with Atlantic depressions, while in spring and summer, during periods of good weather, the levant (easterly wind) blows, a moderate or strong wind that increases its speed when channeled into the strait. Sometimes the wind creates a peculiar cloud on the Rock of Gibraltar, which insists especially in the central part of the city, and can also partially come down towards the plain, generating some fog.

Cloud over the Rock of Gibraltar

Winter, from December to February, is mild, and characterized by sunny periods, alternating with periods of bad weather, with wind and rain. The rains in some years can be particularly heavy or frequent. On the other hand, for its southern location, and moreover in a peninsula, the city is protected from the cold: the temperature rarely drop below 5 °C at night, and it rarely remains below 10 °C during the day.

Spring, from March to mid-June, is mild, and over the weeks has gradually less rain and more sunshine. In March, and sometimes in the first half of April, there may still be heavy rains. In May and June, with the arrival of good weather, the cloud above the rock often forms, so that the weather remains cool and moist.

Summer, from mid-June to mid-September, is warm and sunny, but less than in southern Spain. Typically the temperatures are not very high, and remain below 30 °C; the air is moist and sea breezes blow, sometimes lively. Even in July, and more rarely in August, there may be some quite cool and cloudy days, with highs around 25/27 °C. Sometimes, however, the wind from Africa brings some particularly hot days, with highs about 35 °C.

Autumn, from mid-September to November, is mild; rainy periods gradually increase. In September there are still many warm, sunny days. In November, but sometimes also in October, we are now in the middle of autumn, with a mild weather, but cloudy and rainy as well.

The amount of sunshine in Gibraltar is good in late spring and summer, from May to September, when clear skies prevail (but sometimes as we have seen there can be the local cloud cover and mist), while it's moderate in autumn and winter, when in addition to sunny periods, cloudy and rainy periods are possible.

Cable car in Gibraltar

For swimming, the Alboran Sea is not warm, given the infiltration from the Atlantic Ocean, and it is still very cool in June, when the sea temperature is about 20 °C, then it rises to 22 °C from July to September, and returns to 20 °C in October.
Here are the average sea temperatures.
Sea temperature - Gibraltar
GibraltarJanFebMarAprMayJunJulAugSepOctNovDec
GibraltarJFMAMJJASOND
Sea (°C)161516161720222222201817

When to go

The best time to visit Gibraltar, for walking and hiking, is late spring, from mid-April to mid-June, however, since in the summer usually it's not too hot, you can also choose this season, bearing in mind, however, that if you want to combine the trip with excursions in Andalusia, you will find an intense heat, especially in inland areas (and therefore in this case you can choose April, May and October, as we recommended for Seville). Autumn is mild, but it can be very rainy, as well as winter.
For the sun and the sea, the best time is summer, from June to mid-September. It's better to bring a sweatshirt or sweater for cool and windy evenings, especially in June, but for safety even in July and August, especially if you are sensitive to cold.
Beware of monkeys, which reign in the rock and steal bags from tourists.