In Porto in January 1882 he married Elisa Dantas Gonçalves Pereira (Rio de Janeiro, Rio de Janeiro, December 15, 1865 - April 21, 1942), by whom he had sixteen children. One of his sons in law was writer Aquilino Ribeiro.
He then turned to a second interest; in 1882 was elected to the Portuguese parliament for Lamego, and in 1886 for Coimbra. In 1890 and 1894 was also elected Peer of the Realm by the Coimbra University. During this period he was briefly Minister for Public Works on the Hintze Ribeiro cabinet, in 1893 and created the first labour court in Portugal. Taking a special interest in public education during his political activity he was made part of the Superior Council of Public Education in 1892, and published several books on the subject. Machado was also briefly President of the Directory of the Democratic Party in 1902, and after switching to the Republican Party, was this party's President of the Directory from 1906 to 1909. He was one of the few Monarchists-turned-Republican who switched still during Monarchy.
Once the Republic was proclaimed in 1910 he was made Minister for Foreign Affairs, and ran an unsuccessful campaign for the Presidential elections of 1911. Afterwards appointed ambassador to Brazil, made his political comeback in 1914 to lead one of many brief cabinets the country had in this period. Machado ran again to the Presidency in 1915 and was this time elected President of Portugal. In the course of his term, he would receive Germany's declaration of war (March, 1916), and would visit the Portuguese forces placed in France in the battlefields.
In 1917 the government was deposed by a military coup headed by Sidónio Pais, and Machado went into exile.
Upon Machado's return in 1919 he was elected Senator. He served as Prime Minister from 10 February to 23 May 1921. Once again, in 1925, he achieved the presidential office after President Teixeira Gomes resigned, only to be overthrown a year later (1926) by Gomes da Costa (See: 28th May 1926 coup d'état and Ditadura Nacional). The country remained under a military, then civilian, dictatorship until 1974.
For a second time he went into exile in France, where he continued to be very critical of the Portuguese regime. The German occupation of France in 1940 forced him to seek protection in Portugal, which the government granted him with the condition that he was to be confined to his personal retreat in the northern part of Portugal. It was there in Oporto that he died in 1944.