Hotel Viru stands on the periphery of Tallinn’s Old Town, just outside the city walls. It looks exactly how one might expect a Soviet hotel built in 1972 to look: a huge Modernist box, subjugating the skyline, topped with giant letters spelling out its name. It stands mere metres from the charming cobbled streets of the medieval city, but in architectural and philosophical terms it might as well be on Mars. Or in Moscow.

In Soviet times, any foreign dignitary or journalist arriving in Estonia would be whisked straight from the airport to Hotel Viru. Greeted by the furiously trained doormen and concierge staff, they would be shepherded into elevators and taken up to the top floor – the 22nd – where Tallinn’s finest restaurant resided. From here, the honoured guest could take in the full panorama of the city. They would look out upon the gavelled roofs and stone turrets of the Old Town, weighed down with a thick coat of winter snow; the sharp spires of the Lutheran churches bayoneting the sky; the blue-white ice of the Gulf of Finland locking the land beyond. The hope was that by putting VIPs up here – in a hotel so opulent it had more than 1,000 staff despite having room for just 800 guests – they would send back only the most glowing reports of Tallinn’s wellbeing under the Soviet regime.

Yet, as with most things in the Soviet Union, there was more to Hotel Viru than met the eye. ‘No, foreign visitors did not know about this,’ says Peep Ehasalu, the jovial manager of today’s Hotel Viru. We’re on the famed 22nd floor and he leads me to an anonymous white door at the end of the corridor. ‘There is no 23rd floor button in the elevator, and yet here we are,’ he says. Through the door, a short flight of stairs leads up to the floor that isn’t there, and the two rooms that Peep has spent years trying to convince his bosses to let him convert into a museum. This January, he finally succeeded in his aim. The first room, formerly a broom cupboard, has been converted to a Soviet-style manager’s office, complete with telephones and a TV from the era, as well as what Peep describes as a musty ‘Soviet smell’. It comes from the original, and now rather yellowed, lino flooring. ‘Everyone who was around in Soviet times comments on the smell,’ he says. ‘This is what Communism smelt like.’

The second room has the blinds drawn tight. The walls are lined with bulky green and silver machinery, an array of knobs with buttons and switches covering every metallic surface. This is where four KGB officers would sit each day, intercepting radio waves from Helsinki and sending cables to Moscow. It was also where information from the 60 or so hotel rooms that were routinely bugged would be processed. ‘Certain VIP guests always had certain rooms,’ says Peep, with a knowing smile. ‘Gaps between the walls allowed the rooms to be wired with equipment like this’ – he holds up a long tube that looks like a bicycle pump – ‘and transmitters were attached to the underside of dinner plates and ashtrays.’ The thick, coin-sized microphones don’t exactly scream subtlety, but they were once state of the art. ‘A lot of the staff knew what was going on up here, of course,’ says Peep. ‘It was quite normal. Surveillance was a way of life in this city.’

Tallinn does not feel like a place gripped by subterfuge. The Old Town is so cute that it borders on saccharine. The main square of Raekoja Plats, a cobbled plaza dominated by a Gothic town hall, lies at the epicentre of a web of alleys and lanes leading up to the 13th-century Toompea Castle and the Alexander Nevsky Cathedral. The streets are frozen in white, the iron lamplights jet black against the stonework. Russet rooftops can just be spotted beneath the snow, dripping with exquisite, if murderous-looking, icicles. It is indisputably lovely. However, I am more preoccupied with Peep’s words, and in their wake, the tiny courtyards, cloistered backstreets and narrow lanes to nowhere take on a more sinister edge. They look like good places to run and hide, or to watch and wait.

Just as a child’s chances in life depend in great part on where they are born, so a city’s history can be determined by its location. Tallinn’s crucial strategic position between Russia and the West meant that as the Cold War developed, her pretty streets were seething with spies and double agents from all sides, waiting to be sent either east or west. It was no coincidence that the matchbox-sized Minox camera, a favourite Bond-style spy gadget, was invented in this city.

In 1934, the novelist Graham Greene met a British munitions salesman in Tallinn, who later turned out to be working for British intelligence. Greene subsequently wrote a film script set in the city about a sewing machine salesman who becomes a secret agent. The film was never made, but Greene used the plot for his 1958 novel, Our Man in Havana, changing the location from here to Cuba.

After Estonia was finally annexed by the Soviets in 1944, espionage in the city shifted up a gear, from the film noir glamour of Greene’s 1930s to the relentless, systematic surveillance of the KGB. One of the Russians’ first priorities was to prevent the influx of Western ideas via radio and television signals from nearby Finland. Just as they would later use Hotel Viru as a front for surveillance activity, so they co-opted what is perhaps Tallinn’s most famous landmark into their armoury.

When St Olaf’s Church was built in the 12th century, it was the tallest building in the world. An informal pact by developers has ensured it is still the highest point in Tallinn, and the viewing platform, at the foot of its austere black spire, is proudly recommended by Estonians as the best vantage point in the city. The Soviets, with no time for such sentimental nonsense as civic pride, promptly took over the church and used its spire as their main radio and TV-jamming station. When the authorities turned the St Olaf’s jamming station on, sending out waves of fuzz on the same frequencies as the Finnish broadcasts, it was so powerful that it briefly blocked the reception in Helsinki itself.

At the church I meet local historian Dmitry Saley, who, despite being barely 30, still remembers life under the jam. ‘People built huge homemade receptors to try to catch the Finnish and Swedish signals,’ he explains, before hopping onto a wall to demonstrate how his older brother used to hang over the balcony of his flat with an aerial, searching for any trace of the ‘erotic films’ that Swedish TV was rumoured to show. ‘They knew that these films existed, but no-one had ever seen one,’ says Dmitry. ‘They found a few fuzzy images once: I’ll never forget the look on their faces!’

We are walking towards the Museum of Occupations, which lays out in exhaustive detail the extent to which everyday life in Tallinn was monitored by the Soviets. The route takes us past a grey brick building with blocked-up windows, sitting grimly upon an elegant street of antique shops and cafés. This was once the most feared place in the city – the KGB headquarters. A plaque on the wall reads: ‘Here began the path to death of many Estonians’.

At the museum, we are greeted by curator Heiki Ahonen. A tall, bespectacled man, his quiet demeanour and dry wit belie a life story that is straight from the pages of a political thriller. Heiki’s years in the underground resistance, writing illegal samizdat (dissident activity) newspapers, were rewarded by a stint in a labour camp and exile in West Germany. He has now dedicated his life to recording the means by which Tallinn residents were suppressed by Soviet rule. Much of the equipment on display was donated by former KGB officials. ‘They never want to meet me when they bring their stuff in, or explain what the equipment was for,’ says Heiki. ‘So we work it out ourselves. I think a lot of them are ashamed of what they did.’

He leads us into the museum’s storeroom and shows us the newest arrivals. An innocent-looking metal box folds out into a document photocopier. A pinprick in a false wall has a fish-eye lens on the reverse side, offering a remarkably wide angle view into a neighbouring room. A briefcase, used to carry secret documents, opens up to reveal cardboard compartments, each of which will explosively self-destruct with the turn of a key. It is the stuff of schoolboy imaginations, but the real-life consequences of such fantastical contraptions are made clear by the wooden suitcases on the museum floor. ‘Many families in Tallinn will have one of these suitcases,’ says Heiki. ‘Before prisoners were released from labour camps, they had to make a suitcase to take back any possessions they had left. Everyone knew what a suitcase like this represented.’

For most of Tallinn’s history of espionage, it has been Estonians on the receiving end – blocked from watching and listening freely, kept under constant surveillance and shipped off to labour camps. However, as the Soviet Union disintegrated in the early 1990s, a small group of ordinary Tallinn residents began to subvert the normal dynamic of surveillance, cleverly using the tools and tactics of the KGB against the Soviets themselves. And, like the secret KGB surveillance rooms in Hotel Viru and the radio and TV signal-jamming tower in St Olaf’s Church, this remarkable chapter of Tallinn’s spy story also reveals an unsuspected side to another of the city’s most famous tourist sites – Toompea Castle.

Today, Toompea is home to the Estonian Parliament. It is a small, dignified building of stone and turret, sitting at the centre of the quiet upper-town administrative district. Yet back in 1991, when Aadu Jögiaas was holed up within its walls alongside a handful of his fellow amateur radio enthusiasts, the castle acted much as it did when it was first built in the 13th century – as Tallinn’s last line of defence. Concrete blocks sat on the streets outside, designed to stop tanks breaking in. Thousands of Molotov cocktails rested against the inside wall: the final throw of a bottle-rocket dice.

I meet Aadu in the lobby of my hotel. A heavy-set man with an easy smile and wearing a peaked Ushanka cap, he is excitedly preparing for the opening of an exhibition telling his story. Aadu had been building homemade radios since the 1970s – ‘we swapped vodka for spare parts from the Russian Army,’ he grins – but it was not until Estonia declared independence in 1991 that he began to use his skills for political ends.

Like thousands of other ordinary Tallinn residents desperate to protect their country from Soviet attempts to retake control, he volunteered for the newly formed Estonian Defence League. His radio experience saw him appointed head of national communications. ‘We knew that hardline Communists in Russia would not let [then-reformist Soviet General Secretary, Mikhail] Gorbachev give up control of the Baltic states easily, so we had to be ready.’ In January 1991, the Soviets had attacked Vilnius, the capital of nearby Lithuania, and a similar assault on Tallinn was expected.

The Russians again invaded Estonia on 20 August 1991. By the time they reached the outskirts of Tallinn, Aadu and his team, holed up in Toompea Castle, had picked up their military radio communications. ‘I remember calling home that evening,’ says Aadu. ‘In my mind, I was saying goodbye to my wife and daughter – I didn’t say it in words, but they understood. I knew the army was coming, and I knew what would happen to us if they found out what we were doing.’ On 21 August at 4.30am, Aadu heard the Soviet army announce that they had forcibly entered Tallinn’s TV tower, and were awaiting instructions – presumably to take over all of the strategically important buildings in the city. This was the moment that Aadu and his team had been waiting for. As the military commander started to issue his orders, the radio amateurs, barricaded in Toompea, jammed the frequency – just as the Soviet jammers had blocked Finnish TV signals from St Olaf’s spire for years. He plays me some of the recordings that he made that day. Over a crackly signal, a Russian commander says, ‘Hello, hello, can you hear me?’, before attempting to give the instructions – but these are drowned out by a high-pitched squeal. It sounds as if he is profusely swearing on television and being bleeped out by censors. He tries again, but to no avail. ‘We jammed them for three hours, so successfully that they could not receive any reports,’ says Aadu. ‘Eventually they gave up.’ By now, there were news reports that a conjoining coup in Moscow itself had failed. A short while later, the army withdrew from Tallinn’s TV tower (‘we let that order through,’ laughs Aadu), and Estonian independence was secured – without a single death.

Tallinn’s spy story does not end here. In 2009, Herman Simm, head of security at the Estonian Defence Ministry, was convicted of leaking NATO secrets to a foreign government: no prizes for guessing which country. And Tallinn is now home to the Cooperative Cyber Defence Centre of Excellence, which aims to build up NATO’s defences against cyber attacks. Yet all of this seems very far away as I walk through St Catherine’s Passage, its archways, snow-covered cobbles and artisan workshops making it the loveliest street in a city where loveliness is the bare minimum. A yellow light from the lampposts heats the medieval stonework and a winning burst of warmth and laughter emerges through a crack in the door of a bar. Yet as I again head into the central square, the crunch of my footsteps on the snow rebounding upon the walls, I look up. To my left is the pinprick spire of St Olaf’s Church, straight ahead, the electric glow of Hotel Viru irradiates the sky, and behind me, Toompea Castle looms impassively. The three pillars of Tallinn’s strangled history are, happily, returned to benign landmarks: totemic symbols of a city no longer permanently looking over its shoulder.

The article 'Tallinn’s secret history of espionage' was published in partnership with Lonely Planet Magazine.