Before they traipsed through the sacred Indian grove or studied the hat-shaped spider, before they realized it was a new species or assigned it a peculiar name, scientific researchers Javed Ahmed and Rajashree Khalap discovered Harry Potter.

Ahmed first cracked open the books in his teens. For Khalap, it was in adulthood.

They anxiously awaited the release of The Cursed Child and were delighted to learn of that universe’s expansion in Fantastic Beasts and Where to Find Them. The scientists couldn’t help drawing a parallel between Rowling’s fictional world and the critters still undiscovered in their own.

That sentiment propelled them into the small sacred grove in the southwestern Indian state of Karnataka, in the Shivamogga district, where a “biodiversity hot spot” had been preserved for generations by villagers and their ancestors.

There the scientists, along with colleague Sumukha J. N., found their own “fantastic beasts,” including one spider that looked like a lady bug and another tiny arachnid that brought their love for Harry Potter full circle.

It was shaded brown, triangular shaped and, Ahmed and Khalep agreed, looked identical to Rowling’s mischievous Sorting Hat.

The hat is a staple at the Hogwarts School of Witchcraft and Wizardry, where Harry Potter and his pals spend most of their time throughout the seven books. Brown and tattered, it is placed on the head of each first year student and, through a slit in the aged brim folds, shouts out the child’s house assignment after a period of pondering.

The houses are named after the school’s four founders and known for certain defining qualities.

One founder, Godric Gryffindor, was the original owner of the Sorting Hat.

After the scientists trapped the hat-like spider, examined and dissected it, Ahmed told The Washington Post it became “abundantly clear” they’d discovered a brand new species. That meant its naming fell to the trio.

The tiny brown spider became Eriovixia gryffindori.

In a study of the spider published in the Indian Journal of Arachnology, the three researchers wrote a heartfelt tribute to their etymological inspiration, Rowling and her literary works.

Ahmed thought the Harry Potter-inspired moniker “would be a wonderful way to draw attention to an oft neglected group of organisms,” and Khalap “enthusiastically approved.”

So did J.K. Rowling.

On Twitter, the author responded to a tweet from Ahmed about the study.

“I’m truly honoured!” she wrote. “Congratulations on discovering another #FantasticBeast!”

“When I first read the books, I had no idea I would one day end up naming a species, after such an interesting, fun and whimsical character, and by congratulated by Rowling herself,” Ahmed said. “It was quite a moment.”

And it seems the team’s efforts to spotlight their latest find — the sixth new spider discovery since their research began two years ago — has paid off.

The curious shape of E. gryffindori, which is only 7 mm in length, allows the spider to camouflage itself among the thick vegetation in the Western Ghats Mountains, stretching for about 990 miles along India’s western coast.

The Ghats mountain range is home to a wide array of the country’s species and is recognized as one of the world’s eight “hottest hot spots” of biological diversity, according to UNESCO. But they’ve been threatened by the coffee, tea, rubber and oil palm industries or have been logged, reported Earth Touch News Network.

The range was declared a UNESCO World Heritage Site in 2012 but illegal logging and hunting still threaten the area. Ahmed told The Post the sacred grove where the E. gryffindori was discovered has no legal protection.

The biodiversity they found there, he said, was “staggering,” home to many “fantastic beasts.”

In his interview with Earth Touch, Ahmed joked about a different Rowling character, Aragog, an enormous, hairy, talking spider that lives in the Forbidden Forest at Hogwarts and appears in the second book, Harry Potter and the Chamber of Secrets.

Loading... Loading... Loading... Loading... Loading... Loading...

The creature’s name translates to “leader of the spiders.”

Ahmed told Earth Touch he’s not ruling the name out.

“We might name another cool spider after Aragog!” he said.