When it was rebuilt in 1676, London’s Bethlem Hospital was the most opulent mental asylum the world had ever seen – from the outside. Inside, it was another matter entirely.

It was a London landmark so famous, tourists would visit it alongside Westminster Abbey and the zoo; so notorious, the very name came to mean madness and chaos. It inspired countless poems, dramas and works of art. And the building it was housed in from 1676 appeared so opulent that it was compared to none other than the Palace of Versailles.

This was Bethlem Hospital, more commonly known by its nickname (and the word adapted from it): Bedlam. Almost from the start, Bethlem was much more than a mental asylum. “It was a landmark in the City of London, right by Bishopsgate, and it was also one of the very first to specialise in people who were called ‘mad’ or ‘lunatic’. It becomes this proverbial, archetypal home of madness,” says Mike Jay, author of the book This Way Madness Lies, published to accompany the exhibition Bedlam: the asylum and beyond now at London’s Wellcome Collection. “Any asylum is called a ‘bedlam’ quite early on. Then it becomes a generic term, and then it’s something that means more than an asylum – there are all these metaphors of the world being ‘a great bedlam’.”

Like many old hospitals, Bethlem began as a religious order; it was founded in the 13th Century as a priory dedicated to St Mary of Bethlehem. By 1400, it had become a medieval “hospital” – which then didn’t imply medical care, but simply meant “a refuge for strangers in need”, Jay notes. Those with nowhere else to go turned up at the priory’s doors.

Over time, Bethlem began to specialise in caring for those who weren’t simply poor, but also incapable of caring for themselves – particularly those considered ‘mad’.

By the 17th Century, the asylum was well-known enough to appear in numerous Jacobean dramas and ballads. Often – as in Shakespeare’s plays Hamlet and Macbeth – it was used as a way to explore the popular question of who was mad, who was sane, and who had the power to decide. The last section of Thomas Dekker and Thomas Middleton’s 1604 comedy The Honest Whore, Part I shows this permeability between ‘sanity’ and ‘madness’ and the fear of how easy it would be to slip from one to the other: the asylum’s sweeper says cheerfully, “I sweep the madmen’s rooms, and fetch straw for ‘em, and buy chains to tie ‘em, and rods to whip ‘em. I was a mad wag myself here once, but I thank Father Anselm: he lash’d me into my right mind again.”

After the hospital was re-built, it became even easier to satirise the slippage between sane and insane – in no small part thanks to its opulent architecture.

Unsound foundations

When the second version of the hospital was constructed in 1676, it was unlike any asylum before seen.

Designed by Robert Hooke, a City Surveyor, natural philosopher and assistant to Christopher Wren, its 540ft-long (165m) façade – complete with Corinthian columns and cupola-topped turret – was inspired by Louis XIV’s Tuileries Palace in Paris. It looked over formal gardens with tree-lined promenades. The overall impression was of the French king’s opulent estate at Versailles, not of an asylum. As one writer put it in 1815, “it was for many years the only building which looked like a Palace in London.”

This was going to make London a grander and better place for everybody. A ‘palace for lunatics’, it’s often called – Mike Jay

According to Jay, “It was part of an attempt to recreate London as something grand and modern, instead of the old medieval timber warrens that that part of London consisted of before the fire. And it was a kind of civic pride, and it was a sense of charitable mission: that this was going to make London a grander and better place for everybody. A ‘palace for lunatics’, it’s often called.”

For the first time, meanwhile, private asylums were opening up in the city. The new design was also an attempt to stay on top of what was becoming a contested market; then as now, some of the city’s most jaw-dropping buildings were spurred by capitalist competition.

The interior (and reality) of the hospital, though, was altogether different. Because the ornate façade was so heavy, it immediately cracked at the back. Whenever it rained, the walls ran with water. And as the hospital was built on the rubble next to the city’s Roman wall, it didn’t even have a proper foundation.

The new hospital was, quite literally, putting a pretty face on what many Londoners saw as a messy, distasteful problem. “You had this weird, creaking, collapsing building from the very beginning. It was a contrast everyone picked up on at the time: this grand façade – and how grim it was on the inside,” Jay says.

In 1699, satirist Thomas Brown wrote drolly that the design made you wonder “whether the persons that ordered the building of it, or those that inhabit it, are the maddest.” Four years later, Ned Ward had this to say in his famous periodical London Spy: “We came in Sight of a Noble Pile of Building, which diverted us from our former discourse, and gave my Friend the Occasion of asking me my Thoughts of this Magnificent Edifice: I told him, I conceiv’d it to be my Lord Mayors Palace, for I could not imagine so stately a Structure could be design’d for any Quality inferior; he smil’d at my Innocent Conjecture, and inform’d me this was Bedlam, an Hospital for Mad-folks”.

The protagonist’s response: “I think they were Mad that Built so costly a Colledge for such a Crack-brain’d Society.”

So the sane were mad, and the mad were sane. Perhaps ironically, given the ways in which contemporaries responded to the asylum’s “mad” architects, one of the ways in which people girded themselves against becoming insane themselves was by visiting Bethlem.

In 1681, City governors noted “the greate quantity of persons that come daily to see the said Lunatickes”. Though one figure that’s often given the number of visitors – 96,000 a year – doesn’t have much evidence behind it, as Jonathan Andrews et al note in the book The History of Bethlem, there’s no arguing that Bethlem was a popular attraction. It was also encouraged by the hospital itself, which benefited both from visitors’ donations as well as from any later charitable contributions. As Andrews writes, “In 1610 Lord Percy recorded going to see the lions in the Tower, the show of Bethlem, and the fireworks at the Artillery Gardens. In those days there was nothing odd about permitting or encouraging such a spectacle: all the world was a stage and visiting Bethlem was regarded as edifying for the same reasons as attending hangings.”

In particular, going to the hospital was meant to be an instructive reminder to visitors to “keep baser instincts in check”… lest they, too, wind up on the other side of the bars.

Double meaning

But even as Bethlem the hospital was becoming more and more well-known, it was also turning into an idea with a life of its own. By the 1600s, the most difficult patients were called ‘stark Bedlam mad’. Beggars who only pretended to be ‘lunatics’ – so as to avoid being sent to a workhouse or to prison, as the Relief of the Poor act of 1601 stated that only the poor who were incapable of work be cared for by the parish, while the rest went to workhouses or even prison – were known as ‘Tom o’Bedlams’.

From there, the idea mutated even further, coming to mean not just ‘insanity’ but chaos in general. This interpretation was strengthened by contemporary ideas of London as confused and chaotic. That made Bethlem not only the city’s set piece, but its symbol.

It didn’t just apply to London, either. When William Hogarth updated his final panel in The Rake’s Progress – which he famously set in Bethlem Hospital – in 1763, he added a large British coin to the wall, a way to ensure the audience understood that his Bethlem was a symbol of Britain itself. Even the world was sometimes a ‘bedlam’. As one (possibly fictional) 1722 account of a visit to Bethlem put it, describing the catastrophic collapse of the South Sea Company two years earlier, “all the World became a Bedlam, and London and Westminster made but One great Mad-House.”

In 1815, the palatial Bethlem Hospital, which would have been at the south side of today’s Finsbury Circus, was torn down. The “only” palace-like building in London was gone. Gone, too, are the unfortunate conditions that patients lived in: today, the hospital runs on a state-of-the-art facility in Beckenham, complete with a museum open to the public. But the idea, and the word, lives on.

This story is a part of BBC Britain – a series focused on exploring this extraordinary island, one story at a time. Readers outside of the UK can see every BBC Britain story by heading to the Britain homepage; you also can see our latest stories by following us on Facebook and Twitter.

If you would like to comment on this story or anything else you have seen on BBC Culture, head over to our Facebook page or message us on Twitter.

And if you liked this story, sign up for the weekly bbc.com features newsletter, called “If You Only Read 6 Things This Week”. A handpicked selection of stories from BBC Future, Earth, Culture, Capital, Travel and Autos, delivered to your inbox every Friday.