Anastasio de Gracia Villarrubia was born in 1880 in Mora, Toledo, to a very poor family. He became a bricklayer, and moved to Madrid at the age of 21.
Gracia joined his local union in 1903, and in 1913 joined the Madrid Agrupación Socialista (AS, Socialist Group). He was secretary and president of the Madrid Construction Union, and later general secretary of the Madrid Provincial Federation of the Construction Branch of the Unión General de Trabajadores (UGT, General Union of Workers). He attended the 13th congress of the UGT in 1918 as a delegate of the Bilbao reinforced concrete workers and the masons of Madrid. He was extremely energetic. In a three-year period he visited 125 locations and wrote reports on each for the Committee of the FNE-UGT. He participated in congresses on building and construction in Stockholm, Brussels, The Hague and Vienna.
Gracia became a militant in the Partido Socialista Obrero Español (PSOE, Spanish Socialist Workers' Party). He belonged to the center group of the PSOE. He represented the AS of Daimiel (Ciudad Real) at the extraordinary congress of the PSOE in 1921.
Gracia represented a wide range of sections of the National Building Federation at the UGT congresses. He attended the 15th UGT congress in 1922. In 1923 he ran for election as a socialist for the Inclusa-Getafe district of Madrid, but was not elected. He represented the AS of Tembleque (Toledo) and Novelda (Alicante) in the extraordinary congress of the PSOE 1927. He attended the extraordinary congress of the UGT in 1927 and the 16th congress of the UGT in 1928. He represented the AS of Madrid, Tembleque, Novelda and La Romana (Alicante) in the 12th PSOE congress in 1928. Gracia was a member of the PSOE Executive Committee from July to September 1928, and a member of the UGT Executive Committee from September 1928 to February 1931. In February 1931 he, Julián Besteiro and other executives resigned from the UGT Executive Committee.
In the extraordinary congress of the PSOE in 1931 Gracia represented the AS of Marmolejo (Jaén). In 1931 Gracia won election to the legislature in both Toledo and Jaén, and chose to represent Toledo. He joined the committees on Labor and Records. In 1933 he was elected delegate for Madrid-capital. He was a member of the committee on Labor in the 1933–36 legislature. In 1936 he was elected deputy for Granada. In the 1936–39 legislature he was a member of the committees on Labor and on Finance and Economy.
Gracia chaired the 17th congress of the UGT in October 1932 and was designated to the Executive Committee, but did not join it. From 1932 to 1934 he belonged to the National Committee of the UGT as representative of the Building Federation. When the UGT executive was elected in January 1934 Francisco Largo Caballero was General Secretary. Gracia was president, José Díaz Alor vice-president, Pascual Tomás administrative secretary and Felipe Pretal treasurer. The election represented a victory for those who felt that the union should participate in politics against those led by Julián Besteiro who thought the UGT and the PSOE should not get involved. In January 1936 Gracia resigned the UGT presidency due to objections to the way Caballero and his followers had been courting the Communist Party of Spain.
After the outbreak of the Spanish Civil War Gracia was appointed to the cabinet of Largo Caballero, where he was Minister of Industry and Commerce from 4 September 1936 to 4 November 1936, then Minister of Labor and Welfare until 17 May 1937. The three reformist PSOE ministers in Largo Caballero's government, Indalecio Prieto, Juan Negrín and Gracia, were distant from the prime minister, and tended to work in isolation from each other. The effect was to weaken the PSOE. The three left-socialist members of the cabinet, who were identified with the UGT, would have little to do with the three moderate PSOE ministers.
At a meeting on 13 May 1937 Largo Caballero gave a report on the Barcelona May Days disturbances. The two communist ministers demanded that Largo Caballero dissolve the anarchist Confederación Nacional del Trabajo (CNT) and the Trotskyist Partido Obrero de Unificación Marxista (POUM), and resigned when they were refused. On 14 May 1937 Negrín and Gracia met Largo Caballero to submit their resignations, which exacerbated the cabinet crisis. The outcome was the Largo Caballero resigned and was replaced by the Negrín. One result was to cause the planned Extremadura offensive to be postponed, and eventually cancelled. In Negrín's government, which took office on 17 May 1937, Gracia was Commissioner General of Armament.
After the defeat of the Republicans in 1939 Gracia went into exile in Mexico. In Mexico City he held positions in the Círculo Pablo Iglesias, the Agrupación Socialista Española de México and the Unión General de Trabajadores. He died in Mexico City on 14 March 1981 at the age of 90.