Map from Google - Gibraltar

The climate of Gibraltar, a 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 the freezing cold and the intense heat, because of its location on the strait of the same name, but also because of the presence of the Rock, a promontory overlooking the city, 426 metres (1,398 feet) high.
Here are the average temperatures.
Average temperatures - Gibraltar
GibraltarJanFebMarAprMayJunJulAugSepOctNovDec
GibraltarJFMAMJJASOND
Min (°C)111112131517202020161312
Max (°C)161617182124272726211816
Min (°F)525254555963686868615554
Max (°F)616163647075818179706461

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

The wind blows frequently: in the cold half of the year it blows from the west, together with Atlantic depressions, while in spring and summer, in 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 fogs.

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 during some years can be particularly heavy or frequent. On the other hand, for its southern location, and in a peninsula surrounded by the sea, the city is protected from the cold: the temperature rarely drops below 5 °C (41 °F) at night, and it rarely remains below 10 °C (50 °F) during the day.

Spring, from March to mid-June, is mild, and over the weeks receives 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 (86 °F); 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 (77/81 °F). Sometimes, however, the wind from Africa brings some particularly hot days, with highs about 35 °C (95 °F).

Autumn, from mid-September to November, is mild; rainy periods gradually increase. In September there are still many warm and sunny days. By November, but sometimes also by October, we are now well into 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 the local cloud cover and mist can form), 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 water temperature is about 20 °C (68 °F), then it rises to 22 °C (72 °F) from July to September.
Here are the average sea temperatures.
Sea temperature - Gibraltar
GibraltarJanFebMarAprMayJunJulAugSepOctNovDec
GibraltarJFMAMJJASOND
Sea (°C)161516161720222222201817
Sea (°F)615961616368727272686463

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 it's usually not too hot, you can also choose this season, bearing in mind that if you want to combine the trip with excursions in Andalusia, you will find an intense heat, especially in inland areas (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 swimming and sun bathing, 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 also in July and August, especially if you are sensitive to cold.
Beware of monkeys, which reign in the rock and steal bags from tourists.