The short answer
Only in part. The Habsburgs did not win the Spanish throne, but the settlements of 1713 and 1714 gave them valuable territory in Italy and the Low Countries.
What the war was about
Charles II of Spain died in November 1700 without an heir. His will left the Spanish crown to Philip, Duke of Anjou, a grandson of Louis XIV of France. The Habsburgs rejected that will. Their candidate was Archduke Charles, a son of Emperor Leopold I. The war began in 1701, and a coalition that included Britain, the Dutch Republic and the Habsburg emperor fought France and Spain.
What the Habsburgs gained
The Treaty of Utrecht (1713) and the Treaty of Rastatt (1714) gave the Austrian Habsburgs the Spanish Netherlands, the Duchy of Milan and the Kingdom of Naples. These lands gave them a strong position in Italy and the Low Countries.
What the Habsburgs lost
Philip V kept the Spanish throne and its overseas empire. The powers at Utrecht insisted that the French and Spanish crowns should never be united, which was meant to keep the balance of power. Britain gained Gibraltar and Minorca from Spain in the same settlement.
Why the allies turned against Archduke Charles
Archduke Charles became Emperor Charles VI in 1711, after his elder brother Joseph I died. That made the prospect of one ruler holding both Spain and the Habsburg lands look dangerous to Britain and the Dutch Republic. Their support for his claim weakened, and the allies accepted Philip V on the terms set out at Utrecht.
Why the settlement matters for the 1740s
Charles VI spent the years after 1713 trying to secure his own lands for his daughter, and the Pragmatic Sanction, issued in 1713, was his answer to that problem. The Spanish outcome shaped the diplomacy that followed. For the war that began in 1740, see what led to the War of Austrian Succession.