Since the mid 20th century there has been a series of treaties and multilateral agreements between European countries which have led to the European Union as we know it today.
It all started as a commercial agreement to remove trade barriers for specific goods, and in 1951 the European Coal and Steel Community was created. The next step was the constitution of the European Economic Comunity (EEC) for free trade and the EURATOM Treaty to reach an agreement about nuclear energy. So far, the agreements only work towards economic integration.
But in was in 1992, in the Maastricht Treaty or Treaty of the European Union where the monetary union was designed, and also the fundamentals of the political integration of this club of countries, such as the citizenship and the common foreign and internal affairs policy. The Parliament started to have decision power.
In 1997, the treaty of Amsterdam reformed the institutions for the arrival of new countries, and the same did the Treaty of Nice whose purpouse was to enable proper functioning with 25 member states.
The last agreement was the Treaty of Lisbon in 2009, with the objective of making the Union more democratic, giving more power to the supranational institutions and deciding which issues were left to each countries goverment and which others should be decided by the UE institutions. Nowadays the UE is formed by 28 states.