When you visit Madrid, take a vacation from your vacation with some side trips that help illuminate Spain’s rich history. Four key sights lie within an easy travel distance: El Escorial, Valley of the Fallen, Segovia and Avila — all convenient by car, bus or train.

MONASTERIO DE SAN LORENZO DE EL ESCORIAL

A short drive from Madrid is this giant palace-monastery-mausoleum. In the mid-1500s, King Philip II needed a suitably grand palace to establish his family dynasty, the Spanish branch of the Habsburgs. He also needed a headquarters from which to run a strong, centralized Spanish state.

Philip ruled his huge empire — which stretched from Madrid to Mexico to Manila — from there. El Escorial was built during the Reformation, a time when Catholic Spain was defending the Church against Protestant “heretics.” The enigmatic, introverted and extremely Catholic Philip directed Spain’s Counter-Reformation from this spot. Today, this vast complex is packed with history, art, and royal tombs — offering an evocative trip back to Spain’s most fascinating age.

VALLEY OF THE FALLEN

Just six miles from El Escorial, high in the Guadarrama Mountains, is the Valley of the Fallen. A 500-foot-tall granite cross marks this immense and powerful underground monument to the victims of Spain’s devastating civil war.

In the late 1930s, a million Spaniards died as conservative Catholics and the military slugged it out against secular democrats, anarchists and socialists. The war divided every village. The right-wing Fascists ultimately won, and Franco ruled Spain as its dictator until 1975.

advertisement | advertise on newsday

The sorrowful pieta draped over the entrance to the monument must have had a powerful impact on mothers who came here to remember their fallen sons. Inside, a solemn silence fills the basilica. As if measuring sorrow in distance, the 870-foot-long chamber is far longer than any church in Europe. The line of torch-like lamps adds to the somber ambience.

Franco’s prisoners, the enemies of the right, were put to work digging the memorial out of solid rock. It was a bitter task since Franco’s grave takes center stage inside the basilica. Some Spaniards go there to honor him . . . others go to be sure he’s still dead.

Also interred there, in chapels flanking the main altar, are the remains of about 50,000 soldiers — from both sides — who lost their lives in Spain’s civil war. With every visit, I stare into the eyes of statues of angels holding swords, and think about all the “heroes” who keep dying “for God and country” — at the request of the latter.

SEGOVIA

This historic town of 55,000 with a famous Roman aqueduct is well worth a short visit from Madrid, or en route to Salamanca. Nearly 2,000 years ago, Segovia was a Roman military base in need of water. So Emperor Trajan’s engineers rerouted a stream into town by building a 9-mile-long aqueduct. The massive structure — ingeniously constructed with no mortar — provided water to Segovia until modern times. While locals claim it could still work today, its primary function seems to be providing a focal point for some amazing photographs.

@Newsday

The Plaza Mayor marks Segovia’s old town center, the scene of bullfights until the 19th century. Imagine spectators jamming the balconies screaming, “Toro! Toro . . . olé!” Now, a more genteel form of entertainment graces the square — a bandstand.

The town’s cathedral, built between 1525 and 1768, stands high above its main square. Embellished to the hilt with pinnacles and flying buttresses, it’s a good example of that final, overripe stage of Gothic architecture called “flamboyant.”

Segovia’s Alcazar — or fortress — still seems to defend the far end of town. Once the king’s summer retreat and palace, it burned down and was rebuilt. Like so many castles rebuilt in the 19th century, it’s a fanciful exaggeration barely resembling the original.

AVILA

A short drive from Segovia brings you to the city of Avila, famous for its perfectly preserved medieval walls. For more than 300 years, the town was on the battlefront between Moors and Christians — changing hands several times. Built around 1100, its walls are the most complete in all of Spain. Avila’s cathedral was actually built into the walls. And behind the ramparts, the peaceful streets give a charming look at small-town Spain.

advertisement | advertise on newsday

The Convent of St. Teresa rests upon the birthplace of Avila’s most famous resident. Teresa wrote the most popular spiritual devotions of her age and founded a Carmelite religious order. Pilgrims venerate the saint in the gilded chapel. A case full of relics includes Teresa’s finger, complete with a fancy ring.

If you have a couple days to spare in Madrid, these side trips get you away from the big-city intensity for a bit — all while providing context to Spain’s colorful past.