Costa was the leader of the Portuguese Republican Party, and he was one of the major figures of the Portuguese First Republic. He was a republican deputy in the Chamber of Deputies during the last years of the monarchy. After the proclamation of the republic, he was Minister for Justice during Teófilo Braga's short-lived provisional government, which lasted from 5 October 1910 to 3 September 1911.
During this period, Costa signed the controversial laws which expelled the Jesuits from Portugal, abolished all the religious orders, and established the separation of church and state. These things made him a symbol of the anticlericalism of the First Republic. Also, he was instrumental in the passage of many progressive laws, such as those concerning divorce, family relations, civil registry of marriage, leases of property, judicial reorganization, industrial accidents, and censorship of the press.
He served as Prime Minister of Portugal three times. The first time, he was called by President Manuel de Arriaga to form the government, as the leader of the Republican Democratic Party. This term of office (which he combined with the role of Finance Minister) lasted from 9 January 1913 to 9 February 1914. He returned to power, as Prime Minister and Finance Minister, from 29 November 1915 to 16 March 1916.
Following more political instability Costa was yet again Prime Minister, from 25 April 1917 to 8 December 1917, in a national-unity government nicknamed the Sacred Union, to support Portugal's entrance into World War I. After Sidónio Pais's military coup d'état in December 1917, Costa went into exile in Paris, and though he did sometimes return briefly to Portugal, he never again lived there, even after Pais's assassination in 1918.
After the end of the war, Costa led the Portuguese delegation to the Paris Peace Conference from 12 March 1919, and he signed the Treaty of Versailles of 28 June 1919 on behalf of Portugal. He was the Portuguese representative at the first assembly of the League of Nations.
On 10 July 1919 he was awarded the Grand Cross of the Military Order of the Tower and of the Sword, of Valour, Loyalty and Merit.
On a number of other occasions during the First Republic, Costa received invitations to head the government again, but he always refused. After the 28 May coup d'état, he strongly opposed the military dictatorship; he equally opposed the right-wing civilian Catholic Estado Novo (New State) administration led from 1932 by Dr. Salazar. He died in Paris on 11 May 1937.
Costa was given up at birth as a foundling at the wheel of the Santa Casa da Misericórdia (Holy House of Mercy) of the town of Seia in north-central Portugal. By way of explanation:
"The Santa Casa da Misericórdia was founded [in Lisbon] in 1582, by Jose de Anchieta, a Jesuit. It is opened to the poor of every nation and religion, and affords a refuge to foundlings and orphans. The foundlings are deposited in a revolving wheel, which is placed perpendicularly in the wall. The wheel is divided into four apartments, one of which opens without. The heartless mother who wishes to part with her infant child, has only to deposit it in the box, and a revolution of the wheel passes it within the walls, never more to be reclaimed."
Together with his older brother and sister, he was registered as a son of unknown parents with the name Afonso Maria de Ligório. Ten years later, his parents, Sebastião Fernandes da Costa and Ana Augusta Pereira, recognized him and his brother and sister. They married and readopted the children. Costa re-assumed his birth name in order to conceal the circumstances of his birth.
He was married in Coimbra on 15 September 1892 to Alzira Coelho de Campos de Barros de Abreu (born at Oliveira do Hospital, 20 April 1876; died at Lisbon, 1970), the daughter of Albano Mendes de Abreu, a medical doctor, and his wife, Emília de Barros Coelho de Campos. She was the sister of the writer, José de Barros Mendes de Abreu, who was born at Oleiros, Vilar Barroco, 20 July 1878.
Costa's wife is an ancestor of the modern-day actresses, Sofia Sá da Bandeira and Catarina Wallenstein.