On 4 March 1947 the Treaty of Dunkirk was signed by France and the United Kingdom as a Treaty of Alliance and Mutual Assistance in the event of a possible attack by Germany or the Soviet Union in the aftermath of World War II.

In 1948, the Treaty of Dunkirk alliance was expanded to include the Benelux countries, in the form of the Western Union, also referred to as the Brussels Treaty Organization (BTO), established by the Treaty of Brussels.

Talks for a new military alliance which could also include North America resulted in the signature of the North Atlantic Treaty on 4 April 1949 by the member states of the Western Union plus the United States, Canada, Portugal, Italy, Norway, Denmark and Iceland.

The North Atlantic Treaty was largely dormant until the Korean War initiated the establishment of NATO to implement it, by means of an integrated military structure: This included the formation of Supreme Headquarters Allied Powers Europe (SHAPE) in 1951, which adopted the Western Union's military structures and plans.

In 1952 the post of Secretary General of NATO was established as the organization's chief civilian. That year also saw the first major NATO maritime exercises, Exercise Mainbrace and the accession of Greece and Turkey to the organization.

Following the London and Paris Conferences, West Germany was permitted to rearm militarily, as they joined NATO in May 1955.

The joining of West Germany to the NATO was in turn a major factor in the creation of the Soviet-dominated Warsaw Pact, delineating the two opposing sides of the Cold War.

Doubts over the strength of the relationship between the European states and the United States ebbed and flowed, along with doubts over the credibility of the NATO defense against a prospective Soviet invasion – doubts that led to the development of the independent French nuclear deterrent and the withdrawal of France from NATO's military structure in 1966.

In 1982 the newly democratic Spain joined the alliance (NATO).

The first post-Cold War expansion of NATO came with German reunification on 3 October 1990, when the former East Germany became part of the Federal Republic of Germany and the alliance.

The collapse of the Warsaw Pact in 1989–1991 removed the de facto main adversary of NATO and caused a strategic re-evaluation of NATO's purpose, nature, tasks, and focus on the continent of Europe. This shift started with the 1990 signing in Paris of the Treaty on Conventional Armed Forces in Europe between NATO and the Soviet Union, which mandated specific military reductions across the continent that continued after the dissolution of the Soviet Union in December 1991.

After the fall of the Berlin Wall in Germany in 1989, the organization conducted its first military interventions in Bosnia from 1992 to 1995 and later Yugoslavia in 1999 during the breakup of Yugoslavia.

As part of post-Cold War restructuring, NATO's military structure was cut back and reorganized, with new forces such as the Headquarters Allied Command Europe Rapid Reaction Corps established.

Between 1994 and 1997, wider forums for regional cooperation between NATO and its neighbors were set up, like the Partnership for Peace, the Mediterranean Dialogue initiative and the Euro-Atlantic Partnership Council.

The changes brought about by the collapse of the Soviet Union on the military balance in Europe were recognized in the Adapted Conventional Armed Forces in Europe Treaty, which was signed in 1999.

The policies of French President Nicolas Sarkozy resulted in a major reform of France's military position, culminating with the return to full membership on 4 April 2009, which also included France rejoining the NATO Military Command Structure, while maintaining an independent nuclear deterrent.

The Russian intervention in Crimea in 2014 led to strong condemnation by NATO nations and the creation of a new "spearhead" force of 5,000 troops at bases in Estonia, Lithuania, Latvia, Poland, Romania, and Bulgaria.

At the subsequent 2014 Wales summit, the leaders of NATO's member states formally committed for the first time to spend the equivalent of at least 2% of their gross domestic products on defence by 2024, which had previously been only an informal guideline.