Mayr was born in Adlwang in Upper Austria, the son of a farmer. He studied history and geography at the University of Vienna and earned a doctorate in 1890. From 1897 through 1920 he served as director of the Tyrol State Archives (Tiroler Landesarchiv). In 1900 he became a Professor of Modern History at the University of Innsbruck.
Mayr's political career began under the Austro-Hungarian Empire, when from 1907 to 1911 he was a member of the Imperial Council (Reichsrat) legislature and from 1908 to 1914 of the Tyrolean Landtag assembly. With the breakup of the Empire at the end of World War I, Mayr was in 1919/20 a delegate for the Christian Social Party to the National Assembly drafting the new Constitution of Austria. State Chancellor (Staatskanzler) Karl Renner appointed him a state secretary in his grand coalition government on 17 October 1919.
After Renner's cabinet finally collapsed, Mayr on 7 July 1920 succeeded him as acting "director of the state chancellery", as part of an interim government of his Christian Social Party and the Social Democratic Labor Party (SDAP). Renner himself remained State Secretary for Foreign Affairs until the Social Democrats left the Austrian government after their disappointing outcome in the Austrian legislative election of October 17, to remain in opposition until the end of World War II. From 10 November 1920, with the Constitution's coming into force, the cabinet formed the Austrian Federal Government, with Mayr as Federal Chancellor (Bundeskanzler).
On 20 November 1920, the newly established National Council parliament elected Mayr Chancellor of a Christian Social minority government. He also remained Foreign Minister of the country, until the cabinet resigned on 1 June 1921, in response to a referendum that was called in Styria proposing that the state leave Austria and join Germany contrary to the 1919 Treaty of Saint-Germain-en-Laye.
W. Lazius als Geschichtsschreiber Österreichs, 1894 ("W. Lazius as Austrian Historian")
"Der Generallandtag der österreichischen Erbländer in Augsburg 1525/26", in: Zeitschrift des Ferdinandeums 3(38), 1894 ("The General State Parliament of the Austrian Hereditary Lands in Augsburg, 1525-26")
Erinnerungen an A. Hofer, 1899 ("Memories of A. Hofer")
Die Beziehungen Deutschlands zu Italien, 1901 ("The Relations of Germany with Italy")
Der italienische Irredentismus: Sein Entstehen und seine Entwicklung vornehmlich in Tirol, 1917 ("Italian Irredentism: Its Origins and Development Primarily in Tyrol")