IFC Midnight has taken North American rights to “Ghost Stories,” the supernatural thriller based on the stage production and starring Martin Freeman (“The Hobbit”). The film has its world premiere Thursday at the BFI London Film Festival.

The movie was co-written and directed by Jeremy Dyson (“The League of Gentleman”) and Andy Nyman (“Death at a Funeral”). Lionsgate has the U.K. rights.

“Ghost Stories” stars Nyman as Professor Goodman, a psychologist and skeptic, who has his rationality tested when he stumbles across a long-lost file containing details of three terrifying hauntings. He then embarks on a mission to find rational explanations for the ghostly happenings.

Paul Whitehouse (“The Death of Stalin”) and Alex Lawther (“The Imitation Game”) also star alongside Freeman, known to audiences worldwide as Dr. Watson in “Sherlock.”

Warp Films produced the film in association with Ultimate Pictures and Screen Yorkshire. Catalyst Global Media and Screen Yorkshire were executive producers, and Altitude Film Sales is handling worldwide sales. Altitude’s Mike Runagall negotiated the U.S. deal with Arianna Bocco of IFC Films.