In 1879, Barton umpired a cricket match at Sydney Cricket Ground between New South Wales and an English touring side captained by Lord Harris. After a controversial decision by Barton's colleague George Coulthard against the home side, the crowd spilled onto the pitch and assaulted some of the English players, leading to international cricket's first riot. The publicity that attended the young Barton's presence of mind in defusing that situation reputedly helped him take his first step towards becoming Australia's first prime minister, winning a state lower house seat later that year.[5]

In 1876 Barton stood for the Legislative Assembly in the poll of the graduates of the University of Sydney (who were required to wear gowns for the occasion), but was beaten by William Charles Windeyer 49 votes to 43.[6] He was defeated again for the same seat in 1877, but won in August 1879. When it was abolished in 1880, he became the member for Wellington, from November 1880 to 1882, and East Sydney, from November 1882 to January 1887. At this stage he considered it "almost unnecessary" to point out his support for free trade.[4]

In 1882, he became Speaker of the Legislative Assembly. He was aged only 33, and was the youngest person to have been chosen presiding officer of any Australian legislative chamber. In 1884 he was elected President of the University of Sydney Union. In 1887, he was appointed to the Legislative Council at the instigation of Sir Henry Parkes.[7] In January 1889, he agreed to being appointed Attorney-General in George Dibbs's Protectionist government, despite his previous support for free trade. This government lasted only until March, when Parkes formed a government again.[8]

Barton was an early supporter of federation, which became a serious political agenda after Henry Parkes' Tenterfield Oration, and was a delegate to the March 1891 National Australasian Convention. At the convention he made clear his support for the principle that "trade and intercourse ... shall be absolutely free" in a federal Australia. He also advocated that not just the lower house but also the upper house should be representative and that appeals to the Privy Council should be abolished. He also took part in producing a draft constitution, which was substantially similar to the Australian Constitution enacted in 1900.[4]

Nevertheless, the protectionists were lukewarm supporters of federation and in June 1891, Barton resigned from the Council and stood for election to East Sydney and announced that "so long as Protection meant a Ministry of enemies to Federation, they would get no vote from him". He topped the poll and subsequently voted with Parkes, but refused to take a position in his minority government. After the Labor Party withdrew support and the government fell in October 1891, Parkes persuaded him to take over the leadership of the Federal movement in New South Wales.[4]

Dibbs formed a Protectionist government and Barton agreed to be Attorney-General with the right of carry out private practice as a lawyer. His agreement was based on Dibbs agreeing to support federal resolutions in the coming parliamentary session. His attempt to draft the federal resolutions was delayed by a period as acting Premier, when he had to deal with the 1892 Broken Hill miners' strike, and his carriage of a complex electoral reform bill. He introduced the federal resolutions into the House on 22 November 1892 but was unable to get them considered in committee.[4]

Meanwhile, he began a campaign to spread support for federation to the people with meetings in Corowa and Albury in December 1892. Although he finally managed to get the federal resolutions considered in committee in October 1893, he then could not get them listed for debate by the House. In December, he and Richard O'Connor, the Minister for Justice, were questioned about their agreement to act as private lawyers against the government in Proudfoot v. the Railway Commissioners. While Barton resigned the brief, he lost a motion on the right of ministers to act in their professional capacity as lawyers in actions against the government, and immediately resigned as Attorney-General.[4]

In July 1894, Barton stood for re-election for Randwick (the multi-member electorate of East Sydney had been abolished) and lost. He did not stand for election in the 1895 elections because he needed to support his large family during a period when parliamentarians were not paid. However, he continued to campaign for federation and during the period between January 1893 to February 1897, Barton addressed nearly 300 meetings in New South Wales,[9] including in the Sydney suburb of Ashfield where he declared that "For the first time in history, we have a nation for a continent and a continent for a nation". By March 1897, he was considered "the acknowledged leader of the federal movement in all Australia".[4]

In 1897, Edmund Barton topped the poll of the delegates elected from New South Wales to the Constitutional Convention, which developed a constitution for the proposed federation. Although Sir Samuel Griffith wrote most of the text of the Constitution, Barton was the political leader who carried it through the Convention.[4][7]

In May 1897, Barton was appointed for the second time to the Legislative Council on Reid's recommendations to take charge of the federation bill in the Upper House. This gave Reid's Attorney-General, John Henry Want, a free hand to oppose the bill. In September 1897, the convention met in Sydney to consider 286 proposed amendments from the colonies. It finalised its draft constitution in March 1898 and Barton went back to New South Wales to lead the campaign for a yes vote in the June referendum. Although it gained majority support, it achieved only 71,595; 80,000 was the minimum number for it to pass.[4]

In July 1898 Barton resigned from the Upper House to stand against Reid for election to the Legislative Assembly, but narrowly lost. In September, he won a by-election for Hastings and Macleay and was immediately elected leader of the opposition, which consisted of a mixture of pro-federation and anti-federation protectionists. In January 1899 Reid gained significant concessions from the other states and he joined Barton in campaigning for the second referendum in June 1899, with Barton campaigning all over the state. It passed 107,420 votes to 82,741.[4][8]

In August 1899 when it became clear that the Labour Party could be maneuvered into bringing down the Reid Government, Barton resigned as leader of the opposition, as he was unacceptable to Labour, and William Lyne took his place. He refused an offer to become Attorney-General again. He resigned from Parliament in February 1900 so that he could travel to London with Alfred Deakin and Charles Kingston to explain the federation bill to the British Government. Around the same time on 15 January 1900 Barton published a 28-page United Australia magazine to disseminate an informative narrative for the propositions of a future Federal Government that he hoped to lead.[10] The British Government was adamant in its opposition to the abolition of appeals to the Privy Council as incorporated in the draft constitution; eventually, Barton agreed that constitutional (inter se) matters would be finalised in the High Court, but other matters could be appealed to the Privy Council.[4]

The first and second Prime Ministers of Australia, Edmund Barton and Alfred Deakin, amongst the 1901 cabinet

Few people doubted that Barton, as the leading federalist in the oldest state, deserved to be the first Prime Minister of the new federation. However, since no federal Parliament had yet been established, the usual convention of appointing the leader of the largest party in the lower house could not apply. The newly arrived Governor-General, Lord Hopetoun, instead invited Sir William Lyne, the premier of New South Wales, to form a government.[4][7]

Hopetoun's decision, known as the Hopetoun Blunder, can be defended on grounds that Lyne had seniority. Still, Lyne's long massive opposition to federation until he changed his mind at the last minute caused him to be unacceptable to prominent federalists such as Deakin, who refused to serve under him. After tense negotiations, Barton was appointed Prime Minister and he and his ministry were sworn in on 1 January 1901.[4][7]

Barton's government consisted of himself as Prime Minister and Minister for External Affairs, Alfred Deakin as Attorney-General, Sir William Lyne as Minister for Home Affairs, Sir George Turner as Treasurer, Charles Kingston as Minister for Trade and Customs, Sir James Dickson as Minister for Defence, and Sir John Forrest as Postmaster-General. Richard O'Connor was made Vice-President of the Executive Council and Elliott Lewis was appointed Minister without Portfolio. Only ten days into the life of the government, Sir James Dickson died suddenly; he was replaced on 17 January as Minister for Defence by John Forrest, and James Drake was brought into the ministry as Postmaster-General on 5 February.

The main task of Barton's ministry was to organise the conduct of the first federal elections, which were held in March 1901. Barton was elected unopposed to the seat of Hunter in the new Parliament (although he never lived in that electorate) and his Protectionist Party won enough seats to form a government with the support of the Labour Party. All his ministers were elected, except for Elliott Lewis, who did not stand for election and was replaced by Sir Philip Fysh.[4]

An early piece of legislation of the Barton government was the Immigration Restriction Act 1901, which put the White Australia policy into law. The Labour Party required legislation to limit immigration from Asia as part of its agreement to support the government, but Barton had promised the introduction of the White Australia Policy in his election campaign. Barton stated, "The doctrine of the equality of man was never intended to apply to the equality of the Englishman and the Chinaman".[4] One notable reform was the introduction of women's suffrage for federal elections in 1902.[11]

Barton was a moderate conservative, and advanced liberals in his party disliked his relaxed attitude to political life. A large, handsome, jovial man, he was fond of long dinners and good wine and was given the nickname "Toby Tosspot" by The Bulletin.[12]

For much of 1902, Barton was in England for the coronation of King Edward VII. This trip was also used to negotiate the replacement of the naval agreements between the Australian colonies and the United Kingdom (under which Australia funded Royal Navy protection from foreign naval threats) by an agreement between the Commonwealth and the United Kingdom.[4] Deakin disliked this arrangement and discontinued it, moving for a substantial expansion of Australia's own navy in 1908.[13]

In September 1903, Sir Edmund Barton left Parliament to become one of the founding justices of the High Court of Australia. He was succeeded as Prime Minister by Deakin on 24 September.

On the bench Sir Edmund was considered a good and "scrupulously impartial" judge and adopted the same position of moderate conservatism he had taken in politics. Along with his colleagues Griffith and O'Connor, he attempted to preserve the autonomy of the States and developed a doctrine of "implied immunity of instrumentalities", which prevented the States from taxing Commonwealth officers, and also prevented the Commonwealth from arbitrating industrial disputes in the States' railways. They also narrowly interpreted the Federal Government's powers in commercial and industrial matters.[4]

After 1906, Sir Edmund increasingly clashed with Isaac Isaacs and H. B. Higgins, the two advanced liberals appointed to the court by Deakin. Like Sir Samuel Griffith, Barton was several times consulted by Governors-General of Australia on the exercise of the reserve powers.[14] In 1919, although ill, he was extremely disappointed to be passed over for the position of Chief Justice on the retirement of Griffith.[15]

In 1905, the Japanese government conferred the Grand Cordon, Order of the Rising Sun, and Sir Edmund was granted permission to retain and wear the insignia. The honour was presented in acknowledgement of his personal role in resolving a conflict concerning the Commonwealth's Pacific Island Labourers Act and the Queensland protocol to the Anglo-Japanese Treaty.[4]