Gay people and the city have been a good match since Sodom and Gomorrah. From the molly houses of 18th-century London to 1970s San Francisco via prewar Berlin, the urban environment has always been the natural habitat of queer culture – a place where LGBT people can set their own rules, form their own families, be anonymous when they want to and find company when they fancy it. The countryside, on the other hand, is the place they escape from – a realm of social conformity with limited opportunities for culture, sex or socialising, and perhaps even a site of danger.
That's the stereotype, anyway, both in reality and on screen. Innumerable movies with claims to gay-classic status are inseparable from their urban settings: London has Victim, My Beautiful Laundrette and Beautiful Thing; New York has The Boys in the Band, Paris Is Burning and Torch Song Trilogy; Berlin has Cabaret and Taxi zum Klo; Philadelphia has, erm, Philadelphia. On TV, Queer as Folk was all about Manchester in its original UK incarnation and Pittsburgh in the US remake, while San Francisco is the setting for both new HBO show Looking and the literary adaptation whose title says it all, Tales of the City.
Leave town and things get less comfortable. The Adventures of Priscilla, Queen of the Desert is wholly structured around the idea of gay people in the country as fish out of water, its basically feelgood vibe laced with moments of real macho menace directed at our drag-queen heroines. Brokeback Mountain made icons of its repressed rural protagonists, men whose inability to articulate their desires even to themselves doomed them to lives of regret. The recent Dutch film It's All So Quiet, about a lonely farmer, covered similar emotional terrain. The tragic worst-case scenario is found in Boys Don't Cry, the story of trans murder victim Brandon Teena, in which the combination of deviance from the norm and inability to disappear into the crowd spells doom.
But things aren't always quite so clearcut. It's not as if the city is without its own hazards, from rigid social expectations to poverty, self-loathing to homophobic violence. It's unlikely, for instance, that many youngsters on their way out of the closet would have rushed to book a ticket to New York after watching Cruising. And, as a couple of new films show, the onscreen relationship between gay sexuality and a countryside setting can take many forms: often stifling or threatening but sometimes also liberating, even euphoric.
Tom at the Farm, the latest film by the young Québécois director Xavier Dolan, is an instant classic of gay rural panic. With pictures such as I Killed My Mother, Heartbeats and Laurence Anyways, Dolan has established himself not only as a hugely talented and stylish film-maker but as a firm lover of the city. His characters are sophisticated, savvy urbanites who might not know their emotional arses from their elbows but could find the hippest local bar or vintage store with their eyes closed. When they do venture out of town, it rarely goes well.
So the setup for Tom at the Farm, in which Dolan plays a grieving young man about to visit his late boyfriend's family farm for the first time, is ominous. Its opening images – aerial shots of Tom's little car amid bare, ploughed fields – are reminiscent of the overhead photography of the Torrance family car early in The Shining, evoking the same sense of exposure, isolation and foreboding. This sense only increases as paved roads and phone signals drop away. Nor is it unwarranted: without giving too much away, it's fair to say that Tom's time at the farm is sinister, traumatic and punctuated with violence. At certain points, such as a pursuit through a field of razor-sharp corn, it seems as if nature itself has become weaponised against the arty gay city boy. The film's few images of urban streets come as a blessed relief.
Reading on mobile? Click to watch a clip from Tom at the Farm
On the other hand, Stranger by the Lake, which opens this Friday, might be considered part of the "natural idyll" subgenre of gay cinema. Set entirely at a French lakeside cruising spot, Alain Guiraudie's film uses only natural light and sound, and features only men, often naked. This is a world unto itself in which gay desire and sex – of which the film has plenty – are taken for granted and portrayed not as problematic aspects of social identity but more or less as part of nature. There's not too much distinction made here between the moaning of men getting laid and the rustle of the wind in the trees.
Sometimes, then, being away from the city can mean escaping social expectations. This can be a boon to the superfreaky looking to establish their own queer little world – one thinks of Dr Frank-N-Furter's castle in the woods in The Rocky Horror Picture Show, a deliciously perverted oasis of outrageousness that flourishes off the beaten track. Less flamboyantly, in Desert Hearts the love between older east-coast academic Vivian and younger Nevadan Cay blossoms partly because the former is removed from the norms of her New York life. Similarly, it's only their believing themselves to be out of sight that allows Brokeback Mountain's Ennis and Jack to consummate their desires.
Such setups can work out fine. Les Invisibles, the recent French documentary about older LGBT people, featured a couple of lesbian farmers who had met with nothing but support from their neighbours. But the idyll is rarely peaceful or uncomplicated in feature films. Rocky Horror ends in tears and Ennis and Jack are being watched after all. In Derek Jarman's Sebastiane, the happy, homoerotic gambolling of naked Roman soldiers in the surf is undercut by the knowledge of the bloodshed to come, while the scenes of male lovers playing in floral nature in Jean Genet's Un Chant d'Amour are mere fantasies of incarcerated wretches. Todd Haynes would revisit those scenes in Poison, lacing them with new strains of aggression and humiliation.
In Stranger by the Lake, meanwhile, there turns out to be a killer at large, a threat not just to the ostensibly carefree atmosphere but to life itself. What had been charming – the lakeside spot's separation from the rest of society – becomes dangerous. Both Stranger by the Lake and Tom at the Farm feature highly suspenseful woodland cat-and-mouse pursuits in which the desire for connection is inextricably mingled with the threat of violence. In this sense, both pictures are reminiscent of Thai director Apichatpong Weerasethakul's Tropical Malady, a woozy fever-dream of a film in which a naturalistic story of two young men in love jostles alongside the more mythic tale of a soldier lost in the woods and caught in the spell of a tiger spirit. Nature, desire and transgression overlap, creating a frisson of dangerous uncertainty.
So both the city and the country have their ups and downs. Perhaps it's not surprising, then, to find a thriving middle ground: the gay road-movie. This distinctive subgenre encompasses the operatic red-earth journey of Priscilla, the heart-wrenching campfire odyssey of My Own Private Idaho, the incandescent howl of The Living End, the wide, open skies of Transamerica and the west-coast desert escapades of this year's Bruno & Earlene Go to Vegas. (Honourable mentions might also go to Some Like It Hot and Thelma and Louise.) Always on the move, neither one thing nor the other, the road movie allows for the continual reinvention and rediscovery of the self, even if you don't know quite where you'll end up. Perhaps the most liberating setting of all, then, is neither city nor country but the journey itself.
• Stranger by the Lake is released on 21 February. Tom at the Farm screens in Riverside Studios' Deep Desires and Broken Dreams season on 23 February and goes on general release on 4 April. Bruno & Earlene Go to Vegas is at the Riverside on 21 February.