The federalization of Buenos Aires, that politically separated the city from the Buenos Aires Province to put it under direct control of the national government, was a constant aspiration of the other provinces of Argentina since the formation of the national state. However, due to harsh political debates around the issue, federalization was only achieved in 1880, more than sixty years later.
The first successful Constitutional Convention, which took place in 1853, defined in its 3rd article the status of Buenos Aires:
The Authorities that exercise the Federal Government reside in the City of Buenos Aires, which is declared capital of the Confederacy by a special law.
The terms Argentine Confederacy were used in those days to designate Argentina (usage would evolve until today, where the terms Argentine Republic are used instead). This article could not be enforced, as Buenos Aires withdrew from the convention, forming a separate state. When the province rejoined the country in 1860, an amendment was made to the constitution, which changed article III in a subtle way:
The Authorities that exercise the Federal Government, reside in the city that is declared Capital of the Republic by a special law of Congress, previous cession made by one or more provincial legislatures from the territory to be federalized.
This change did not declare Buenos Aires national capital right away, and left an open door for another city to be declared so. Although the city was made capital in the end, the change was satisfactory for the porteños as well as the rest of the country, and so it remained.
During the Assembly that dictated the first constitution in 1853, the egalitarian representation with two delegates for each province in the Constitutional Convention provoked the rejection of Buenos Aires, who pretended a representation proportional to the population and whose interests were highly threatened by a federal government.
Trying to attenuate the conflict, the constitutional delegates didn't fix the federal condition of Buenos Aires city in the constitution itself, but though a special law, sanctioned a few days after the signature of the constitution.
Buenos Aires ignoring the powers of the constitutional convention drove the province to revolt and separate from the Argentine Confederation until 1860, when it reincorporated in exchange of several modifications of the original constitutional text, and the suspension of the federalization.
The relationship between the de federal authorities and those of Buenos Aires continued to be hostile; Mitre's Partido Unitario Nacionalista urged for electoral abstention, and Buenos Aires governor Carlos Casares strengthened the separation of his power of administration and police, of the federal one. Avellaneda attempted reconciliation by pardoning the revolters, but the measure had little effect.
When in 1880 Mitre's perspectives of reaching the presidency seamed again dim, since Avellaneda gave wide support to Roca; an armed confrontation seamed again imminent. Carlos Tejedor, new governor of Buenos Aires and supporter of Mitre, made allusion of the federal government being his guest.
In response to the belligerent attitude Avellaneda arranged to temporarily move the Federal Government to the town of Belgrano, by that time outside the Province of Buenos Aires. The Senate, Supreme Court and part of the Lower Chamber moved there before the national army, commanded by Roca, sieged Buenos Aires.
Though Mitre gave support to the insurrection, it served as mediator during the signature of an agreement for the disarming of the militias and Tejedor's resignation.
The congress, from its provisory location in Belgrano —in a building currently serving as home to the Museo Histórico Sarmiento—, dissolved the legislature of Buenos Aires. On August 24 of 1880 Avellaneda presented a project of law to declare Buenos Aires city the capital of the republic, under direct control of the federal government; on September 21 the law was approved. With the ratification of the city's legislature days later, the Buenos Aires city was finally separated from its homonymous province, whose capital would be moved in 1884 to the city of La Plata, built to serve that purpose.
In 1987, president Raúl Alfonsín proposed moving the national capital to Viedma, in an effort to attenuate the population centralization in Buenos Aires that the country experiences up to this day. The federalization law was approved in May but proved so unpopular that the transfer never took place, and the law was annulled by a decree in 1989.