Which Hogwarts house would you be in? There are four options, and everybody fits into one. The brave and chivalrous are put in Gryffindor. Patient and loyal types head to Hufflepuff. Ravenclaw is for the witty and intelligent. The cunning and ambitious — and potentially evil — are destined for Slytherin. In the Harry Potter books, a pugnacious talking hat, known as the ‘Sorting Hat’, carries out the selection.

If you are like me and under 35, you probably didn’t need that explaining. Almost every young person who can read has read Harry Potter — 450 million copies have been sold worldwide. Not to do so was an act of rebellion. On Monday, fans will celebrate the 20th anniversary of the first book’s publication — two decades on and J.K. Rowling’s tales of wizardry and witchcraft continue to bewitch us, even though we are meant to have grown up.

The ‘Potterverse’ is the millennial universe. It informs the way we see ourselves and the way we look at the world; our moral imagination. If you have ever wondered why young people are often so childish in their politics, why they want to divide the world between tolerant progressives and wicked reactionaries, it helps to understand that.

Harry Potter may be a literary fantasy but for many it is also a substitute religion in a secular era. The books are about the fight between good and evil, and the power of magic. They teach you that bigotry must be fought at all costs, that tolerance and difference must be celebrated. The great symbol of malevolence is Harry’s nemesis, Lord Voldemort — or ‘He Who Must Not Be Named’. He wants to rid the wizarding world of Muggles (people from non-wizarding heritage) and is obsessed with the idea of blood purity.

The Harry Potter generation sees real-life Voldemorts everywhere. Donald Trump, Nigel Farage, Marine Le Pen, Vladimir Putin, Viktor Orbán — all are compared to the Dark Lord. Following Trump’s election, a number of articles drew parallels between his administration and the Potterverse. ‘How Harry Potter Helps Make Sense of Trump’s World’ was the title of one. ‘Who Said It — Steve Bannon or Lord Voldemort?’, another. A service was launched that replaced the names of Trump’s cabinet wherever they appeared online with those of ‘Death Eaters’ — the group of wizards led by Voldemort. At Harvard, students launched the ‘Resistance School’ to fight back against Trump’s agenda, comparing themselves to ‘Dumbledore’s Army’, a force set up in the books to combat ‘dark magic’. Articles such as ‘Ten Things Dumbledore’s Army Taught Us about Activism and Political Resistance’ were published. At anti-fascism protests across the world, placards reading ‘Dumbledore’s Army’ or ‘Hermione wouldn’t stand for this’ have become a common sight.

J.K. Rowling is not only very wealthy thanks to the books, films and now the stage play, Harry Potter and the Cursed Child; she is also a major voice in world affairs. In 2006, the year before the final Potter book, Twitter was launched. It almost sounds like something from the world of Hogwarts, where owls deliver the post. Rowling is prominent on Twitter and her army of almost 11 million followers is always keen to hear what she has to say about contemporary politics. Following Trump’s proposed ban on Muslims entering the US, Rowling tweeted that ‘Voldemort was nowhere near as bad’. When one Trump supporter threatened to burn her Harry Potter books, Rowling tweeted back: ‘Guess it’s true what they say: you can lead a girl to books about the rise and fall of an autocrat, but you still can’t make her think.’

British politics is also seen through the lens of Harry Potter — which is fitting, given that the books are set here. Earlier this year, a poll revealed Rowling, a prominent unionist, was considered a better person to lead the campaign against Scottish independence than Jeremy Corbyn. The author has also tweeted, ‘Corbyn. Is. Not. Dumbledore’ in case there was any confusion. Rowling has no love for the hard left. She is a Labour supporter but has frequently criticised its leader. She has also condemned the misogyny being directed towards the Prime Minister: ‘Just unfollowed a man who I thought was smart and funny, because he called Theresa May a whore,’ she tweeted earlier this month.

Corbyn may not be Dumbledore, the benevolent headmaster of Hogwarts, but I suspect the majority of Potter fans prefer him to May. The Prime Minister said during the campaign that she was a fan of the books — all politicians have to do so now — yet she refused to compare herself to any of the characters. This was not a good enough answer, so the Potterverse decided for her: May was Dolores Umbridge, a sinister bureaucrat who tortures Harry.

In the EU referendum, 75 per cent of 18- to 24-year-olds voted Remain. Could it be that the messages contained in the Harry Potter series helped direct Britain’s younger generation? Harry’s uncle, Vernon Dursley, is the archetypal Little Englander. He lives in boring suburbia, at 4 Privet Drive in Little Whinging, Surrey, and reads the Daily Mail. He’s a narrow-minded, mean-spirited man who makes his nephew sleep in a cupboard under the stairs. No self-respecting Potter fan would want to be associated with him — or his political views.

Prior to the referendum, Rowling confirmed what many suspected: horrible Uncle Vernon would have voted Leave. In the wake of this revelation, an ironic piece was published on the website of the US TV channel Comedy Central, suggesting how other characters would have voted. Heroes such as Harry Potter, Hermione Granger and Hagrid would all have voted In — as would Dumbledore, because he’s ‘seen what wartime is like too many times’. On the Out side were some of the books’ most notorious villains: Professor Snape, Draco Malfoy and Bellatrix Lestrange (who would vote Out ‘to restore the primacy of true Brits’). ‘The Potterverse is pro-Remain’ wrote one fan, who urged everyone to ‘Vote in sync with Rowling to keep the monsters once again at bay.’

In the days before the referendum, Rowling published an essay on her website entitled ‘On Monsters, Villains and the EU Referendum’, in which she argued that a string of ‘monsters’ created by the Out campaign were being used to terrify voters into voting Leave. When someone tweeted asking her to ‘do something’ about the result, Rowling replied: ‘I don’t think I’ve ever wanted magic more.’ Following the attack near Finsbury Park mosque last Sunday, the author was quick to accuse Nigel Farage of being responsible. ‘Let’s talk about how the #FinsburyPark terrorist was radicalised,’ she said, attaching a picture of the former Ukip leader in front of the now infamous ‘Breaking Point’ poster, which showed a queue of refugees. The tweet received 25,000 likes within a few hours.

Rowling’s political heroine is Jessica Mitford, whom she describes as a ‘self-taught socialist’. Mitford was the ‘red sheep’ of her family, who once described how she tried ‘to write things I hope will be useful in the struggle’. Rowling has continued to update the world she created to ensure it fits with how the Harry Potter generation view their own political struggle. She has revealed Dumbledore was gay and that Hogwarts would have been a ‘safe place’ for LGBT students.

Meanwhile Emma Watson, who played Hermione in the films, has become a prominent campaigner for gender equality. Last month she was awarded MTV’s first ‘gender-neutral’ award. Groups such as The Harry Potter Alliance have been created, to turn ‘fans into heroes’. Originally set up in 2005 to draw attention to human rights violations in Sudan, the non-profit organisation campaigns on issues relating to immigration, gay rights, labour rights, mental health, body image and climate change. If Harry Potter can save the world, why can’t his fans, too?

The Potterverse, then, keeps developing. Yet it is a naive landscape in which most problems are solved by magic. To believe in it, even ironically, is to divide people into goodies and baddies, and ignore the complexity of reality. For all the joy that Harry Potter brings to its millions of readers, the world cannot be sorted by a magical hat.

Lara Prendergast and Nick Hilton debate Potter politics on the Spectator Podcast.

At anti-fascism protests, placards reading 'Dumbledore's Army' have become a common sight

Spectator.co.uk/podcast Lara Prendergast and Nick Hilton discuss Potter politics.