San Marino, officially the Republic of San Marino, is a landlocked country in Southern Europe, completely surrounded by Italy. Located on the northeastern slopes of the Apennine Mountains, it is the larger of two microstates within the Italian Peninsula, the other being Vatican City. San Marino is the fifth-smallest country in the world, with a land area of just over 61 square kilometres (24 sq mi) and a population of 34,042 as of 2025 which in 2026 dropped to 33,559. Its capital, the City of San Marino, sits atop Monte Titano, while its largest settlement is Dogana, in the municipality of Serravalle. San Marino claims to have been founded in AD 301 and to be the oldest extant sovereign state, and the oldest constitutional republic. It is named after Saint Marinus, a legendary stonemason from the Roman island of Rab (in present-day Croatia), who is said to have fled persecution under Emperor Diocletian to have established a monastic community on Monte Titano, where he built a small chapel. The country has a rare constitutional structure: the Grand and General Council, a democratically elected legislature, selects two heads of state, the Captains Regent, every six months. They are chosen from opposing political parties, and serve concurrently with equal powers and preside over several institutions of state, including the Grand and General Council. Only the Federal Council of Switzerland follows this same structure, except with some modifications due to its immensely larger size.
San Marino is a member of the Council of Europe and uses the euro as its official currency, but is not part of the European Union. The official language is Italian, although the traditional regiolect is Sammarinese, a dialect of Romagnol. Its economy is based on finance, industry, services, retail, and tourism, and it ranks among the wealthiest countries in the world by GDP (PPP) per capita. It hosts the Parliamentary Assembly of the Mediterranean. San Marino was also the first currently-existing state to abolish the death penalty (in 1865), although it had not actually been used since the 1400s. In 2025 San Marino was ranked 29th on the Human Development Index.
According to accounts that were first recorded centuries after he is suggested to have lived, Saint Marinus left the island of Rab in present-day Croatia with his lifelong friend Leo, and went to the city of Rimini as a stonemason. After the Diocletianic Persecution following his Christian sermons, he escaped to the nearby mountain Monte Titano, where he built a small church and thereby founded what is now the city and state of San Marino. According to William Miller, these accounts of the origin of San Marino "are a mixture of fables and miracles, but perhaps contain some grains of fact". The earliest historical evidence for a monastic community in San Marino dates to the 5th or 6th century AD, when a monk named Eugippus recorded that another monk had lived in a monastery in the area.
In 1291, San Marino appealed to the Bishop of Arezzo, Ildebrandino Guidi di Romena, against the contribution demands by the Vicario del Montefeltro. Jurist Palamede di Rimini decided in favour of San Marino and recognised its tax exemption from tributes demands of Montefeltro. In 1296, when Guglielmo Durante was the governor of Romagna, Sammarinesi appealed to Pope Boniface VIII against the further requests by the Montefeltro podestas regarding tributes. Abbot Ranieri di Sant'Anastasio was assigned to judge the dispute. A long process was held using various witnesses and sources to determine San Marino tax exemption status. The verdict was probably in favour of the autonomy of San Marino, as later the State did not pay taxes to the Montefeltro.
In 1320, the community of Chiesanuova chose to join the country. In 1463, San Marino was enlarged by the inclusion of the communities of Faetano, Fiorentino, Montegiardino, and Serravalle; since then, the country's borders have remained unchanged. In 1503, Cesare Borgia, the son of Pope Alexander VI, occupied the Republic for six months until his father's successor, Pope Julius II, intervened and restored the country's independence. On 4 June 1543, Fabiano di Monte San Savino, nephew of the later Pope Julius III, attempted to conquer the republic, but his infantry and cavalry failed as they got lost in a dense fog, which the Sammarinesi attributed to Saint Quirinus, whose feast day it was.
After the Duchy of Urbino was annexed by the Papal States in 1625, San Marino became surrounded by the papal states. This led to it seeking the formal protection of the Papal States in 1631, but this never amounted to a de facto Papal control of the republic. The country was occupied on 17 October 1739 by the legate (Papal governor) of Ravenna, Cardinal Giulio Alberoni, but independence was restored by Pope Clement XII on 5 February 1740, the feast day of Saint Agatha, after which she became a patron saint of the republic.
The advance of Napoleon's army in 1797 presented a brief threat to the independence of San Marino, but the country was saved from losing its liberty by one of its regents, Antonio Onofri, who managed to gain the respect and friendship of Napoleon. Due to Onofri's intervention, Napoleon promised in a letter to Gaspard Monge, a scientist and the commissary of the French Government for Science and Art, to guarantee and protect the independence of the Republic, even offering to extend its territory according to its needs. The offer was declined by the regents, fearing future retaliation from other states' revanchism.
During the later phase of the Italian unification process in the 19th century, San Marino served as a refuge for many people persecuted because of their support for unification, including Giuseppe Garibaldi and his wife Anita. Garibaldi allowed San Marino to remain independent. San Marino and the Kingdom of Italy signed a Convention of Friendship in 1862. The government of San Marino made United States President Abraham Lincoln an honorary citizen. He wrote in reply, saying that the republic proved that "government founded on republican principles is capable of being so administered as to be secure and enduring".
In March 1877, a new postal agreement allowed San Marino to issue the first stamps in representation of its own sovereignty, becoming a significant revenue source, showcasing national symbols like the Three Towers.
During World War I, when Italy declared war on Austria-Hungary on 24 May 1915, San Marino remained neutral and Italy adopted a hostile view of Sammarinese neutrality, suspecting that San Marino could harbour Austrian spies who could be given access to its new radiotelegraph station. Italy tried to forcibly establish a detachment of Carabinieri in the republic and then cut the republic's telephone lines when it did not acquiesce. Two groups of ten volunteers joined the 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. The existence of this hospital later caused Austria-Hungary to suspend diplomatic relations with San Marino.
After the war, San Marino suffered from high rates of unemployment and inflation, leading to increased tension between the lower and middle classes. The latter, fearing that the moderate government of San Marino would make concessions to the lower class majority, began to show support for the Sammarinese Fascist Party (Partito Fascista Sammarinese, PFS), founded in 1922, and styled largely on their Italian counterpart. PFS rule lasted from 1923 to 1943, and during this time they often sought support from Benito Mussolini's fascist government in Italy. During World War II, San Marino remained neutral, although it was wrongly reported in an article in The New York Times that it had declared war on the United Kingdom on 17 September 1940. The Sammarinese government later transmitted a message to the British government stating that they had not actually declared war.