Thirty Years' War: Bavaria, Cologne, France and Sweden sign the Truce of Ulm.

The Truce of Ulm (German: Waffenstillstand von Ulm) (also known as the Treaty of Ulm) was signed in Ulm on 14 March 1647 between France, Sweden, and Bavaria. This truce was developed after France and Sweden invaded Bavaria during the Thirty Years' War. Both invading nations forced Maximilian I, Elector of Bavaria, to conclude the truce and renounce his alliance with Emperor Ferdinand III. However, Maximilian broke the truce on 14 September and returned to his alliance with Ferdinand.

The Thirty Years' War was a conflict fought largely within the Holy Roman Empire from 1618 to 1648. Considered one of the most destructive wars in European history, estimates of total deaths caused by the conflict range from 4.5 to 8 million, while some areas of Germany experienced population declines of over 50%. Related conflicts include the Eighty Years' War, the War of the Mantuan Succession, the Franco-Spanish War, and the Portuguese Restoration War.

Until the 20th century, historians considered it a continuation of the German religious struggle initiated by the Reformation and ended by the 1555 Peace of Augsburg. This divided the Empire into Lutheran and Catholic states, but over the next 50 years the expansion of Protestantism beyond these boundaries gradually destabilised Imperial authority. While religion was a significant factor in starting the war, scholars generally agree that its scope and extent was driven by the contest for European dominance between Habsburgs in Austria and Spain, and the French House of Bourbon.The war began in 1618 when Ferdinand II was deposed as King of Bohemia and replaced by Frederick V of the Palatinate. Although the Bohemian Revolt was quickly suppressed, fighting expanded into the Palatinate, whose strategic importance drew in the Dutch Republic and Spain, then engaged in the Eighty Years War. Since ambitious external rulers like Christian IV of Denmark and Gustavus Adolphus of Sweden also held territories within the Empire, what began as an internal dynastic dispute was transformed into a far more destructive European conflict.

The first phase from 1618 until 1635 was primarily a civil war between German members of the Holy Roman Empire, with external powers playing supportive roles. After 1635, the Empire became one theatre in a wider struggle between France, supported by Sweden, and Spain in alliance with Emperor Ferdinand III. This concluded with the 1648 Peace of Westphalia, whose provisions included greater autonomy within the Empire for states like Bavaria and Saxony, as well as acceptance of Dutch independence by Spain. By weakening the Habsburgs relative to France, the conflict altered the European balance of power and set the stage for the wars of Louis XIV.