A tax haven that grew rich from secret banking, the miniscule nation is now under huge pressure from much bigger, more powerful countries to clean up its murky financial system.

Its stoutly defended walls have offered a haven from persecution since the 3rd century AD, but San Marino has turned its attention to the thousands of tax dodgers suspected of falsely claiming to live within its borders.

Next month the government will start conducting a census of its 31,000 inhabitants designed to winkle out people claiming to live in San Marino, where they pay low taxes and have access to generous pensions and health care, when in fact they reside in Italy or other countries.

“There’s a lot of worried people,” said Roberto, a hotel manager working in the republic’s warren-like mediaeval centre, where soldiers in Ruritanian uniforms mount a changing of the guard every half hour outside Government House.

“This time the authorities mean business. They are threatening to revoke people’s residency.”

The probe into exactly who is entitled to live in the world’s oldest republic, and Europe’s third smallest state after the Vatican and Monaco, is part of San Marino’s efforts to clean up its tarnished image. It is also reeling from a money laundering scandal at its biggest and most respected bank, and from a downturn in tourism caused by the global recession.

For The Most Serene Republic of San Marino, as it is officially known, the last few months have been anything but tranquil. Many Sammarinesi say that the country is going through its worst crisis since the second world war, when as a neutral state it provided protection for 100,000 refugees and was mistakenly bombed by the RAF.

“It’s been a very bad time for San Marino,” foreign minister Antonella Mularoni said in her fresco-decorated office. “But we are responsible for many of the problems we have encountered.”

The trouble started in May, when five senior executives at its biggest bank, Cassa di Risparmio della Repubblica di San Marino, were arrested by Italian police on suspicion of money-laundering and “highly irregular activities”.

Italy’s central bank then placed the bank’s consumer finance group, Delta, under bankruptcy proceedings, sending further shock waves through the mountain citadel, which lies six miles from the Adriatic Sea, near the Italian resort town of Rimini.

San Marino suffered another blow in July when Italy declared war on tax evasion and announced an amnesty for Italians who repatriated money that they had hidden in offshore centres.

The Italian media has latched onto its tiny neighbour’s troubles with glee, running stories under headlines such as “San Marino’s dirty money” and “Scandal in San Marino”.

San Marino was so angry with the coverage that it made a formal complaint to the government of Silvio Berlusconi. “Relations with Italy have been very, very tense,” said Mularoni. “But we cannot afford to have a bad relationship. Italy can create problems for us because we are so small and because we rely on them for so many things – even our water.”

San Marino has scrambled to fulfil 12 financial transparency conditions in order to be removed from a list of suspect tax havens this month by the Organisation for Economic Co-operation and Development.

As the government hauls itself into line with the global crackdown on tax refuges, ordinary Sammarinesi are still smarting from the blow to their reputation.

“We are hard-working people and we feel very hurt and offended by all this,” said director of tourism Antonio Macina. “It’s the Italians coming here who are causing all the problems, not Sammarinesi going to Italy.”

Last year two million day-trippers flocked to San Marino for its duty free shops, impeccably restored battlements perched on top of a 2000-ft limestone cliff, and unusual museums, including one dedicated to medieval instruments of torture. So far this year there has been a 7.5% drop in numbers due to the global downturn.

Unemployment has risen, with the amount of money paid by the government to finance temporary layoffs jumping more than six-fold.

The government expects the economy to contract by up to 12% this year, with an even tougher 2010 ahead.

Scrutiny of its banking system has shone an unwelcome light on an obscure corner of Europe, which until now was known largely to collectors of coins and stamps and for its quaint Guard of the Rock, a militia who dress in braided green tunics, red trousers and white spats.