The southern part of Württemberg was the core of the medieval duchy of Swabia; Württemberg N of Stuttgart was part of Franconia. The various territories were subdivided among the branches of the family, but in 1482 Count Eberhard V declared the indivisibility of the holdings. Württemberg was raised to ducal rank in 1495. In 1519, however, the Swabian League of cities, fearing the rising power of Württemberg, expelled Duke Ulrich I from his domains, and in 1520 it sold the duchy to the newly elected emperor Charles V.
Ulrich, a turbulent individual, never ceased in his attempts to recover his lands. A Protestant convert, Ulrich secured (1534) the help of Philip of Hesse, a leading defender of the Reformation, and, through Philip, of Francis I of France; at the same time the peasants of Württemberg were rising against the unpopular government of King (later Emperor) Ferdinand I. At the battle of Lauffen (1534), Ulrich and Philip routed Ferdinand's troops. Ferdinand was obliged to restore Württemberg to Ulrich, although nominally Ulrich was to hold the duchy as a fief from Austria. Immediacy under the empire was restored only in 1599.
With Ulrich's return, Lutheranism was introduced. However, large parts of S Württemberg remained in the hands of the house of Hapsburg and of a number of powerful abbeys; these territories were incorporated into Württemberg only later. As a result, a large minority of the present population is Roman Catholic.
Württemberg was repeatedly the scene of fighting in the wars of the 17th and 18th cent. Duke Frederick II (1754–1816), through his alliance with Napoleon I, obtained the rank of elector in 1803 and became king of Württemberg as Frederick I in 1806, after joining the Confederation of the Rhine. Between 1802 and 1810 the territories of Württemberg were more than doubled and reached their final frontiers after an alliance with France under Napoleon. Frederick retained both his royal title and his lands at the Congress of Vienna, after having passed (1813) from the French to the Allied camp.
William I, his successor, granted a liberal constitution in 1819. During the reign (1864–91) of King Charles, Württemberg sided against Prussia in the Austro-Prussian War of 1866, joined Prussia's side in the Franco-Prussian War of 1870–71, and became (1871) a member of the German Empire. Charles's successor, William II, abdicated in 1918, and Württemberg joined (1919) the Weimar Republic. After World War II, N Württemberg was a part of the temporary state of Württemberg-Baden, and S Württemberg was a part of the temporary state of Württemberg-Hohenzollern until the two were joined as Baden-Württemberg in 1952.