While Italy declared war on Austria–Hungary on 23 May 1915, San Marino remained neutral. Italy, suspecting that San Marino could harbour Austrian spies who could be given access to its new radiotelegraph station, tried to forcefully establish a detachment of Carabinieri on its territory and then suspended any telephone connections with the Republic when it did not comply.
Two groups of 10 volunteers each did join Italian forces in the fighting on the Italian front, the first as combatants and the second as a medical corps operating a Red Cross field hospital. It was the presence of this hospital that later caused Austrian authorities to suspend diplomatic relations with San Marino.
Although propaganda articles appeared in the New York Times as early as 4 June 1915 claiming that San Marino declared war on Austria–Hungary, the republic never entered the war.
San Marino in the 1920s, still a largely agrarian society, experienced political turmoil influenced by the events inFascist Italy, culminating in June 1921 in the murder in Serravalle of Italian doctor and Fascist sympathiser Carlo Bosi by local leftists, which led to condemnation by the surrounding Italian population and threats of retaliation by Italian squadristi. The government decided to ask Italy for help in the form of a detachment of 30 Carabinieri. As in Italy, Fascism eventually took over government of the Republic, the Sammarinese Fascist Party causing the Socialist newspaper Nuovo Titano to cease publication.
The 1930s was an era of public works and reinvention of the Republic's economy, with the construction of the San Marino-Rimini railway that connected it to the Italian railway network and modernization of the country's infrastructures that paved the way to its present status as a major tourist destination.
World War II
San Marino was mostly uninvolved in the Second World War. In September 1940, press reports claimed that it had to have declared war on Britain in support of Italy; however, this was later denied by the Sanmarinese government.
On 26 June 1944, it was bombed by the British Royal Air Force which mistakenly believed it had been overrun by German forces and was being used to amass stores and ammunitions. The railway was destroyed and 63 civilians died during the operation. The British government later admitted the bombing had been unjustified and that it had been executed on receipt of erroneous information.
San Marino's hope to escape further involvement was shattered on 27 July 1944 when Major Gunther, commander of the German forces in Forlì, delivered a letter from German headquarters in Ferrara to San Marino's government declaring that the country's sovereignty could not be respected if, in view of military requirements, the necessity of transit of troops and vehicles arose. The communiqué, however, underlined that wherever possible occupation would be avoided.
Fears were confirmed when on 30 July a German medical corps colonel presented himself with an order for the requisition of two public buildings for the establishment of a military hospital. On the following day, 31 July 1944, in view of the likely invasion by German forces, the state sent three letters of protest: one to Joachim von Ribbentrop, German Foreign Minister, one to Adolf Hitler and one to Benito Mussolini, the latter delivered by a delegation to Serafino Mazzolini, a high-ranking diplomat in the Italian Ministry of Foreign Affairs. Demanding to meet Mussolini with the intention to ask that its neutrality be respected, the following day Mazzolini took them to see Mussolini, who promised to contact the German authorities and intervene in favour of San Marino's request.
San Marino was a refuge for over 100000 civilians who sought safety on the passing of Allied forces over the Gothic Line during the Battle of Rimini, an enormous effort of relief by the inhabitants of a country that at that time counted only 15,000 people.
Despite all this, the Germans and Allies clashed on San Marino's soil in late September 1944 at the Battle of Monte Pulito; Allied troops occupied San Marino after that, but only stayed for two months before returning the Republic's sovereignty.
Post-War period and modern times
After the war, San Marino became the first country in Western Europe to be ruled by a communist party (the San Marinese Communist Party, in coalition with the San Marinese Socialist Party) through democratic elections. The coalition lasted from 1945 to 1957, when the fatti di Rovereta occurred. This was the first time anywhere in the world, when a communist government was democratically elected into power.
Women gained voting rights in 1960. Having joined the Council of Europe as a full member in 1988, San Marino held the rotating chair of the organisation during the first half of 1990.