The city was first founded by a Spanish gold-seeking expedition led by Pedro de Mendoza, on 2 February, 1536. In 1539, attacks by the native people forced the settlers away and in 1541 the old site was burned. In 1580, Juan de Garay from Asuncion, which is now the capital of Paraguay, established a permanent settlement here.
The city remained under the authority of a Spanish viceroy in Peru until 1776. It was the capital of viceroyalty of the Rio de la Plata, including much of present-day Argentina, Uruguay, Paraguay and Bolivia. The early days of the city were annoying for the residents. The Spanish insisted on some rules that frustrated the traders of the city. The people were not happy with the Spanish rule. After noticing a deep resentment in locals, Charles III of Spain gradually simplified the trade restrictions. Finally in the late 1700s, he declared Buenos Aires an open port. However, most of the residents were hoping for separation from the Spanish Empire.
During the attacks on Rio de la Plata, the city was invaded twice in 1806 and 1807 by British forces. But the local militants managed to drive back the forces both times. Eventually when Spain was busy with Peninsular War, the armed people of town council expelled the Spanish Viceroy and founded a provisional representative government on May 25, 1810. This day, May 25 is now celebrated as a national holiday or May Revolution Day all over the country. Later on, the Spanish ruler officially declared the Independence in 1816.
Buenos Aires had remained an important centre for liberal and free-trade ideas in Argentina. However, some of the other provinces were having Catholic approach to the political and social issues. These contrasting views became the reason for some conflicts later. After May 25 Revolution, the forces of the city tried to obtain the approval of other provinces. Many of these missions resulted in violent clashes.
In the 19th century, the city faced two naval blockades, first by French from 1838 to 1840 and another joint Anglo-French blockade from 1845 to 1848. The city hold out its position and eventually the external powers stopped their demands. In 1853, the internal conflicts forced Buenos Aires province to separate out from Argentina. But after the National political unity, the city became the capital of Argentina in 1862. Further tensions between the city and province resulted in the detachment of the city from province.
During the second half of 19th century, the city flourished by all means. The economic power of the city increased with the help of wealth generated by the fertile pampas and railroad construction. The city developed into a multicultural metropolitan and graded itself with the major European capitals. By 1920s, it became the favoured destination for immigrants who came to city from all over Europe and from Argentina's provinces and neighbouring countries too.
Due to some economic crises, some citizens moved to the outskirts of the larger cities resulting in the creation of some new villas around the town. In 1935, the population jumped to the 3.5 million mark. The city experienced bombing on June 16, 1955 which killed 364 civilians. In 1970s, it suffered from the fighting between left-wing revolutionary movements (Montoneros, E.R.P. and F.A.R.) and the right-wing paramilitary group Triple A. Jorge Rafael Videla which led to the military coup of 1976. Some developments plans took place during the years of dictatorship.
Certain bomb explosions between 1992 and 1994 destroyed the buildings and several Jewish organizations. In 1996, under the 1994 reform of the Argentine Constitution, the city gained autonomous status and held its first mayoral elections. In 2004, the city again underwent one of the greatest non-natural tragedies in Argentine history. A fire at Republica Cromagnon nightclub became the cause for death of 200 people.