Map from Google - Madrid

Madrid, capital of Spain, has a slightly continental climate, with moderately cold winters, and hot and sunny summers. The city is in fact at the center of the Meseta, the Iberian plateau, at about 2,100 feet above sea level.
Here are the average temperatures.
Average temperatures - Madrid
Min (°F)343739435057646357484137
Max (°F)505461647282909081685752

Winter, from December to February, is relatively mild: the average January temperature is 42 °F. The rains, brought by Atlantic depressions, are quite frequent, but generally not abundant. Days can be mild, especially when the Azores anticyclone settles on the Iberian Peninsula, bringing periods of good weather even in winter, with highs around 55/59 °F, but typically the nights remain cold, with lows near freezing. Sometimes, at night and in the early morning, especially in December and January, fog can form.
Every now and then, cold waves may occur, with snowfalls and frosts. Here are the lowest temperatures reached in recent decades at the airport of Cuatro Vientos: January 1985: 17.5 °F; February 1986: 17.5 °F; February 2012: 19.5 °F.

Summer, from June to August, is hot and sunny; the mean temperature in July is 77 °F. The temperature is often torrid during the day, given that highs can easily reach 95/97 °F, with peaks of 105 °F, however the air is dry, so the heat is more bearable. In addition, at night the temperatures remain fairly cool, swinging typically from 59 °F to 68 °F.

Spring and autumn are mild and characterized by a variable weather, with periods of good weather, alternating with the passage of Atlantic disturbances, which bring clouds and rain.

The amount of sunshine in Madrid is great in summer, when clear skies prevail: in July there are on average 12 hours of sunlight. Sunny days are possible throughout the year: after all even from November to January there are no less than 4/5 hours of sunshine per day.

The rains are not abundant: the total annual rainfall is 18 inches, and in fact the landscape of the plateau is semi-arid, especially during the summer months. The rains, however, are quite frequent from October to April. In May and more rarely in summer, a few afternoon thunderstorms may break out, but generally from June to August it almost never rains.
Here is the average precipitation.
Average precipitation - Madrid
Prec. (in)1.61.4122.


When to go

The best periods to visit Madrid are spring and autumn, especially in May, June and September. In June, however, it can already be hot. In April, it can be a little cold, especially in the first half of the month, and still at night in the second half of the month, when the days are generally pleasant.
September is also a good month, but at the beginning it can still be hot, while during the month the first rains can occur. In October, the air is often mild, but the days are getting shorter, the rains are more frequent and it can be a little cold at night.
Those who can stand the heat can choose July and August, but must be prepared to stroll around the city in hot weather.
The temperature range between day and night is often high, so it is useful to dress in layers and to have something warm for the evening: even in summer, you may want a sweatshirt for the coolest hours.