When summertime rolls into Madrid, the temperatures soar, but the humidity drops and precipitation becomes practically nonexistant, so it's not all that uncomfortable. The 2100 foot altitude of Madrid, making it one of Europe's highest capitals, means that it tends to cool off nicely at night, when Madrid comes to life.
Late October through November is the rainiest time in Madrid, with the rainfall peaking at 2.1 inches in November. Spring showers are quite possible, but we're looking at a place that doesn't get a whole lot of rain historically.
Madrid's altitude and dryness contribute to the wide range of temperature in the days of July and August, when the nights cool down considerably from the daytime highs.
March thorugh mid-June are the most desirable times to visit Madrid--but September thorough mid-October are good as well. Residents of Madrid tend to leave in the summer, and if you want room and like the dry heat, Madrid might be best in the summer.
Try refreshing the page if info doesn't appear