The question of precedence among nations is one that arose in the context of international meetings and among ambassadors. At the Council of Constance in 1415, disputes broke out among delegations of the various nations on who should enter after whom, be seated next to whom, and speak after whom. Various temporary solutions were adopted at the time, but with the explicit proviso that they were not to set any precedent.
One dispute became particularly famous, that between the French and Spanish ambassadors in about every court of Europe, starting in the 16th century, each claiming precedence over the other. The French version of the story is that French ambassadors always enjoyed precedence until the king of Spain happened to be Holy Roman Emperor (1519 to 1555). After that date, the Spanish king ceased to be Emperor, but tried nevertheless to continue to have precedence over the French king, an attempt that the French ambassadors resisted for decades. The dispute was resolved ultimately by a treaty between France and Spain in 1761, the so-called Pacte de Famille. The solution adopted was that, in each European court, the most senior ambassador (as determined from the date of acceptance of his credentials) was to have precedence.
The solution was adopted as a general rule for all ambassadors in Europe at the Congress of Vienna. Annex 17 of the final act of 9 June 1815, rank was determined by the date of official notification of an ambassador's arrival in a capital. Political alliances and family relationships between ruling houses ceased to confer any kind of precedence; the precedence of papal envoys, however, being unchanged by the new rule. This regulation remains in effect to this day (see article 16 of the 1961 Vienna convention on diplomatic relations). Catholic countries often give absolute precedence to the Papal Nuncio, independently of his seniority of tenure.
In an attempt to put an end to the quarrels between ambassadors to the Holy See, Pope Julius II set forth an order of precedence. It was only binding in the Papal States, and was rejected by the Holy Roman Emperor as not binding on him. The list became obviously moot as regards all kings and princes who left the Catholic Church soon after.
The list appears in the diary of the Master of Ceremonies of the Pope, Paris de Grassis, for the year 1505 (cited in Notices et Extraits des Manuscrits du Roi, vol. 2, p. 624, 1789).
Another version of this list appears in Rousset de Missy, and it shows some modifications (as well as the incluion of the grand duke of Tuscany, whose title was not conferred until 1569).
See also the styles used in international correspondance by the chancery of France.