The war that occurred in Shakespeare's time was the Anglo-Spanish War between England and Spain, and it was fought mainly as a religious conflict between Protestant England and Catholic Spain. Phillip II of Spain considered himself a defender of the Catholic faith, while Elizabeth I of England re-established royal supremacy over the Church of England in defiance of the Pope.
Though never officially declared, the Anglo-Spanish War was fought intermittently between 1585 and 1604. Shakespeare married Anne Hathaway in November 1582. His actions between his marriage and the early 1590s have not been documented historically, but by 1592 he was a popular dramatist and a member of an acting company called the Lord Chamberlain's Men. He composed most of his plays in the late 1500s and early 1600s, which puts most of his professional life in direct juxtaposition with the Anglo-Spanish War.
The most famous event of the Anglo-Spanish War was the British defeat of the Spanish Armada. In May 1588, the Spanish fleet of about 130 ships, 8,000 seamen and 19,000 soldiers set sail from Lisbon. The English fleet, led by Charles Howard and Sir Francis Drake, numbered no more than 100 ships. Over the course of a lengthy battle, the English, aided by the weather, defeated and scattered the Spanish fleet. The Spanish lost about 15,000 men, and only about 60 ships made it back to Spanish ports.