Consider the cloak: that heavy, full-length piece of outerwear most often associated with epic fantasy franchises, and specifically, Harry Potter. It’s not something you’d wear to class, not if you value practicality—and yet somehow it remains the most iconic part of the wizarding school uniform.

But in the non-magical world, Portuguese university students have been wearing cloaks to class day in, day out, more or less since higher education was invented. They are the indisputable pioneers of the trend—so much so that many would swear, under Veritaserum if needed be, that J.K. Rowling was inspired by the Portuguese when picking out the outfits for her young wizards. Although Rowling has never been explicit about her inspiration for the cloaks, she wrote part of what would become Harry Potter and the Sorcerer's Stone while living in Porto, Portugal, in the 1990s. Tour guides often point out the cloaked university students, whom Rowling must have seen walking to and from class, as the likely inspirations behind the Hogwarts dress code.

The look stems from the history of post-secondary education in Portugal, which has some of the oldest universities in the world. When the country's first university—the University of Coimbra—was created in 1290 in Lisbon, teaching was a religious vocation (as was learning), and so the medieval campus was teeming with clergymen. There wasn’t a student uniform, exactly, but the mish-mash of men from different religious orders did result in a student look: a dark, severe ensemble that civilian students began to approximate in the centuries that followed. As late as 1850, the all-male student body at the University of Coimbra was still wearing knee-length cassocks over shorts and knee socks. A long cloak topped off the whole outfit, lending a decidedly clerical look to the decidedly civilian students.

Things changed, dramatically, in the latter half of the 19th century. The progressive spirit of the era replaced the old-fashioned shorts with a practical three-piece suit, composed of black frock coat, waistcoat, and tailored pants—and so the standard male university uniform, or traje, was born. The cumbersome old cloak very nearly went out of commission then, but the boys had reportedly grown so attached to its drama that they kept wearing it over the new suits. School authorities allowed the cloak to remain, proudly anachronistic, to sweep the cobblestones of Coimbra another day. When the country’s second and third universities were founded in 1911, in the cities of Lisbon and Porto, students rushed to adopt the same weirdly popular suit-and-cloak combo.

Students from the Orfeão Universitário do Porto, a student association at the University of Porto, pictured in their trajes in 1956.Lpmateus87, Wikimedia // CC BY-SA 4.0

Girls didn’t get a standard uniform until 1945, when the Orfeão Universitário do Porto, a student association at the then-young University of Porto, accepted the first female members into its roster. (Before then, women didn't have any particular school attire, although they were sometimes told to wear all black so as not to stand out.) Members of the Orfeão were expected to perform traditional Portuguese singing and dancing in full uniform, and the girls rose to the occasion by suiting up in their very own, alternate version of the traje. They found their inspiration in the stripped-down practicality of military women’s uniforms and settled on a knee-length trapeze skirt and boxy three-button jacket. The cloak, of course, was the final touch, which quickly caught on at other schools.

Today, there are over 300,000 university students in Portugal, a respectable number of whom routinely wear the traje to class. It is no longer mandatory, as it once was, but it doesn’t need to be. To wear this historic uniform is to embrace and broadcast one’s identity as a student—although it’s also to be frequently confused with a Harry Potter cosplayer. Foreign visitors to Portugal sometimes make that mistake, but they should know the opposite is likelier to be true: Local students have been wearing cloaks to class since long before Harry Potter was cool.