He participated as a volunteer in the First World War, initially as an artillery Lieutenant and later in the Army Air Corps; from 23 April 1918 he was a pilot in the 4th SVA Section, based in Treviso and Vedelago, which from 20 October became the 56th Squadron, earning a Silver and two Bronze Medals of Military Valor.
From 1919 to 1921 he served in the Army Air Corps in Libya, participating in operations against the Senussi rebels, after which he returned to Italy; he played an important role in the creation of the Regia Aeronautica, which he joined immediately after its establishment in 1923.
He later returned to Italy, where he was hired by the Stacchini powder factory in Rome along with his lifelong friend Roberto Lordi, who had fought beside him during World War I and who had also become a general in the Regia Aeronautica until being likewise forced to resign in 1935.
After the German occupation of the capital, both generals joined the Clandestine Military Front; Martelli Castaldi established contact with the Allies, distributed explosives to the partisans and organized armed groups.
Before his execution, Martelli Castaldi wrote a last message in the wall of his cell, which he shared with Carabinieri Lieutenant Colonel Giovanni Frignani: "When your body will no longer be, your spirit will be even more alive in the memory of those who remain.