The history of wine making in Spain dates back several thousand years, as it does in most European countries. The Phoneticians were the first to cultivate wine in Spain on an organized level, around 1000 BC. When Rome occupied Spain in 100 BC, Spanish wine was traded throughout Europe under the Roman Empire. At this point it was often used as a blending wine to raise alcohol levels of wines made in cooler areas of Europe.
In 711, when the Moors conquered Spain, wine was technically outlawed under Islamic law. It appears that wine trade still exists though, as it was taxed by the Moors. The Moors also developed the technique of distillation, which they used to make medicinal alcohol. This technique very likely may have been adopted by the Spaniards to make Brandy, and to make the spirits used to fortify Sherry.
Phylloxera did not hit Spain until the 19th century, significantly after it had devastated most of Europe's vineyards. As a result, Spain was able to benefit from discoveries made about grafting techniques, so when the disease did spread, they were able to use the new grafting techniques to save themselves. The same held true for Powdery Mildew, which also started the trend of French winemakers coming to Spain. While the French waited for their fields to recover from the mildew, they foraged south into Spain, bringing French winemaking techniques with them, establishing wine areas that are still vital to Spain's wine industry today. They also introduced the use of oak barrels as a wine making technique.
In 1872, José Raventós used the French méthode champenoise to make a champagne style sparkling wine, which is today called Cava. Spain had previously tried to recreate Champagne using Champagne grapes, but was not successful. José risky innovation was to use native Spanish grapes to make Cava. The risk paid off, as in 2001 Cava overtook Champagne as the most consumed sparkling wine in the world.
The Spanish Civil War in the 1930's and World War II took a huge toll on Spanish winemaking. Many of the vineyards were devastated by the wars, and the conflict with other nations virtually eliminated the trade of wine. After the war was over, many of the smaller estates could not afford to replant their grapes, and died off. For a long time only large conglomerates produced very ordinary table wine. On top of this Franco's medieval dictatorship that followed prevented Spain from modernizing in all fassets of its civilization. When he died in 1975, Spain took great pains to learn modernizing techniques, and the wine industry began to develop once more. As a result, Spain's wine history was almost restarted in the 70's, far behind the innovations of the French and Italians.
Spain became a member of the European Union in 1986, and with that came a great deal of financial support for the wine industry. So in fact, the production of quality wine in Spain came quiet a while after the United States. As you might expect then, Spain is still in its infancy of understanding its own terroir and what it takes to produce top quality wine. While there are many fine producers using the latest techniques, there are also many who have not caught up with them. It is risky, for example, to order a siginificantly aged red wine in a restaurant in Spain today, because those wines were not often stored the way they should have been, and they are often cooked beyond drinkability. There are however, many fine wines coming out of Spain, and the potential for more to develop is ever-present.