You cannot evict an idea. Such is the message of defiance from Occupy. But it is not entirely true. For the whole point of Occupy is that it's not just an idea bouncing around the internet. Occupy is stubbornly about the physical reality of space. Others may write books and organise seminars. Occupy puts up tents. It takes up space. It is there.

Except, of course, now it is not. On Tuesday morning a dismal metal fence surrounded St Paul's Cathedral, protecting it from those who for several months now have fought successfully to voice a widespread concern that global capitalism has not been working for the good of all. The cathedral was at pains to point out that St Paul's remained open and that the purpose of the fence was to allow urgent cleaning to take place.

And that says it all. It never was an issue of access – that was a convenient legal argument. Occupy was just too messy, too in your face.

On Monday night, under the cover of darkness, the bailiffs moved in, supported by hundreds of police, some in fluorescent jackets, some in black riot gear. As 2 o'clock approached, the lights dramatically went out on the cathedral front, only for them to come back on moments later after several spotters had positioned themselves high up on the cathedral portico. The bell struck two. I whispered to my neighbour in the crowd words from a former dean: "For whom the bell tolls; it tolls for thee."

In the end, it all looked more menacing than it was. Credit to Occupy that it stuck by its commitment to leave peacefully. It is little credit to the church that some of those praying on the steps of the cathedral were roughly handled.

Occupy has taken a lot of stick over the months. Yet in an age with worrying levels of political indifference, this was politics with passion and commitment. All that stuff about it being full of middle-class poseurs was a deliberate misdirection. Thermal imaging cameras showed most of the tents were unoccupied at night. Except I don't know of many self-respecting protesters who would be tucked up in their tents at 11 at night when the images were shot.

Another attempt at slander was that it was full of druggies and a magnet for the homeless. Though I don't see that this was any sort of slander at all.

Occupy's welcome and care for the vulnerable contrasted sharply with the indifference of a City that didn't seem to give two hoots. On ceremonial occasions, I have sometimes been given a posy of flowers to hold in procession. It was a hangover from the days when the important people were given something nice to smell so that rancid poverty didn't linger too heavily on the nose. I won't be holding those flowers again. No. There was always genuine conviction and passion in the camp.

My own direct involvement began on the morning of 16 October last year. I was canon in residence at the time – a bit like the officer on watch on the good ship St Paul's. I arrived at 7.20am – I remember checking my watch – to make sure all was going to be workable for an 8am communion service. A line of police stood shoulder to shoulder along the entire front, blocking any sort of access to the cathedral. Worshippers would soon start arriving for the service. Everything else was sleepy and quiet. So I asked the police to stand aside to allow the services begin. I was asked if the protesters were welcome to church. Of course they were. Everyone is welcome to church. All this was entirely uncontroversial stuff. But to some, it turned me into the leader of some latter-day peasants' revolt.

Of course, Occupy was never like that. It all began with the editor of a little-known Canadian anti-consumerist magazine called Adbusters. On 13 July he published a stylish publicity poster depicting a ballerina poetically balancing on the top of the symbolic brass bull of the New York Stock Exchange. "Occupy Wall Street. Bring tent."

That is pretty much all he did. He created what Richard Dawkins has called a meme – a cultural unit of thought that perpetuates itself through imitation, though mimesis. The idea was to cross-pollinate the energy of the Arab Spring with a sense of outrage at the pathologies of global capitalism as expressed by the Indignado movement in Spain. "We are not goods in the hands of politicians and bankers," was their banner.

Politics as mimesis is perfectly suited to the age of social networking. On Twitter, we follow. @OccupyLSX, with over 26,000 followers, is still the little brother of @OccupyWallStreet, with over 152,000.

But this is how Occupy worked its way into the cultural bloodstream. It is how the protesters came – to Zuccotti Park in New York and pouring out from the St Paul's tube station in London and to places in nearly 100 countries all over the world. When Occupy reached London on 15 October few people expected it to last as long as it did.

The original aim had been to protest in Paternoster Square and target the London Stock Exchange. But when crowds began to arrive on Saturday afternoon, the square had been blocked off with barriers. So much of the land in the City is privately owned and thus legally easy to defend against unwelcome demonstrations. The steps of nearby St Paul's Cathedral were an obvious place to sit down and wait to see what happened. Many thought the whole thing would be over in a few hours. Nobody ever intended to occupy St Paul's.

That first night was balmy and the atmosphere electric, charged with purpose. Half way between a rally and a pop concert, the steps of Wren's magnificent cathedral provided the perfect amphitheatre for the drama that was to play itself out over the coming months. The banners were terrific. "We are the 99%". "Capitalism is crisis". "Now is the Winter of our Discount Tents". And of course: "What would Jesus do?"

The demand for social justice was being trumpeted slap bang in the boiler room of global capitalism.

And then there were those V for Vendetta masks. Originally from a cult comic book by the English writer and anarchist Alan Moore, the masks intimidated many. They were, of course, a reference to Guy Fawkes who, in Moore's fictional version, succeeded in blowing up the Houses of Parliament after it had been taken over by fascists.

But on that first morning, what those masks reminded me of was Shelley's great poem The Mask of Anarchy. The point about that poem was that it was the government that had become the anarchists, loosing violence and destruction upon society. And if I feared the consequences of eviction in those early days, it was because of Shelley.

On a hot summer's day on 16 August 1819, members of the 15th Hussars light cavalry charged a crowd of more than 60,000 protesters gathered at St Peter's Field in Manchester. They had assembled to express a pent-up frustration at the economic hardships being experienced by those on the wrong end of the Industrial Revolution.

Public finances had been squandered on expensive foreign wars against Napoleon. And political representation, such that it was, gave ordinary people – especially in the north – no voice in the Palace of Westminster. During the ensuing slaughter, a dozen or so protesters were killed and hundreds injured.

This event led directly to the founding of the Manchester Guardian in 1821.

Out in Italy, Shelley attacked the "motley crowd" of priests and lawyers he believed responsible for the massacre. Thank God the situation at St Paul's did not turn out to be like that. In large degree, good sense prevailed from Occupy and from those who were evicting them. Credit is due to the police. Nonetheless, the words of that poem set the struggle between the 99% and the 1% in a much broader historical context:

Rise like lions after slumber

In unvanquishable number –

Shake your chains to earth like dew

Which in sleep had fallen on you –

Ye are many – they are few.

… You cannot evict an idea.

Dr Giles Fraser is the former canon chancellor of St Paul's Cathedral. He resigned in October 2011 in protest at plans to forcibly remove Occupy protesters from its steps