“Most people don’t know how they’re going to feel from one minute to the next. But a dope fiend has a pretty good idea. All you gotta do is look at the labels on the little bottles.”

That’s Matt Dillon as Bob Hughes in Gus Van Sant’s Drugstore Cowboy, offering one last revelatory insight via voiceover narration toward the end of the film. Portraits of drug addiction tend to wallow in spiraling miseries, like a hurricane that gathers strength and grows more destructive as it reaches landfall. Movies and television have taught us that drugs are about compulsion, chasing a high that steadily diminishes, and the film acknowledges that, too, with Bob talking about how he and his crew “played a game you couldn’t win”. Yet Drugstore Cowboy ties that compulsion to organization and elaborate bits of drug logic and superstition, which suggests more structure to an addict’s behavior than the ordinary person’s. Staying high means planning for the next hit.

When the film was released 30 years ago, it was mere months after sex, lies and videotape changed the landscape for independent film, bringing some sense of order to what was then a disparate patchwork of small-time distributors and modest urban arthouses. (Drugstore Cowboy was put out by Avenue Pictures.) Yet a movement was taking shape around certain soon-to-be-brand-name auteurs: John Sayles, Joel and Ethan Coen, Hal Hartley, Spike Lee, Jim Jarmusch and others, who were all in the early stages of their careers. For his part, Van Sant had won some attention for his self-financed debut feature, 1986’s Mala Noche, a $20,000 black-and-white production that showed a sensitivity to the hard lives and doomed romanticism of young adults living on the margins.

Based on James Fogle’s memoir, Drugstore Cowboy could be a companion piece to Midnight Cowboy from 20 years earlier, in that both are about modern outlaws living hand-to-mouth in urban squalor, running short-term scams into long-term trouble. Only Van Sant’s film has a funny, offbeat, episodic quality that doesn’t negate the heartbreak and tragedy that’s peppered throughout it, but gives it dimension and surprising verve. As Bob and his crew of drug addicts – his wife Dianne (Kelly Lynch), his best friend and muscle Rick (James Le Gros), and Rick’s teenage girlfriend Nadine (Heather Graham) – knock off drugstores in Portland and other cities across the Pacific north-west, they often look like merry pirates, plundering all the pharmaceutical treasures they can get their hands on. Van Sant even stages a sequence that makes them look like the Beatles clowning around in A Hard Day’s Night.

More than anything, Drugstore Cowboy is a film defined by its attention to lived-in detail: the anecdotes and harrowing capers from Fogle’s book, the specific habits and philosophies of its characters, the overcast vividness of its setting, which extends to the various apartments, motel rooms and flophouses that serve as temporary quarters to these transient junkies. The smash-and-grab robberies planned by Bob each have their distinctions, but his modus operandi is to have the others create a distraction while he raids the back counter for powerful opioids like Dilaudid to shoot up their arms. In one sequence, that involves Nadine faking an epileptic seizure in the front of the store while Bob dives toward the back; in another, Dianne and Rick stage a hilarious impromptu demolition derby near the hospital as Bob takes a crowbar to a locked cabinet inside.

Kelly Lynch and Matt Dillon in Drugstore Cowboy. Photograph: Allstar Picture Library/Alamy Stock Photo

Keeping themselves high takes planning – when they leave Portland to go “crossroading”, Bob has small stashes waiting at different stops, and always has contingencies to avoid arrest – but Van Sant spends plenty of time hanging out with them and getting a feel for their quirks, habits and morphine dreams. Dillon plays the beautiful, romanticized rebel Van Sant would turn to again with Keanu Reeves and River Phoenix in My Own Private Idaho, but Bob’s focus on drugs is so myopic that he’s constantly turning schemes over in his head, and isn’t always aware of life around the fix. In one of the film’s best scenes, Bob tells the story of why they can’t have a dog – or even mention a dog – because they once had a cutie named Panda who inadvertently led the police to their home. He remembers the incident bitterly; Dianne, in a piercing moment, remembers that this dog she loved was put down afterwards.

Drugstore Cowboy is a teeming repository of such low-key specifics: weird hexes like the “hat on the bed” and the reverse mirror, goofy anti-drug PSAs on TV (“the last time I dropped acid I decided to make a self-portrait. Groovy, isn’t it?”), Bob’s inability to even acknowledge Dianne as a sexual partner, the surreal image of the crew losing their motel room to a sheriffs’ convention, and William Burroughs turning up as a defrocked, death-haunted priest who Bob figures has shot a million bucks’ worth of drugs into his arm. The film reflects the contradiction of penniless users who live by the seat of their pants and have their days rigidly structured by addiction.

The end of the road awaits these characters with absolute certainty – we know as much from the beginning, when Bob narrates the events that brought him to the back of an ambulance – but Van Sant takes the scenic route. There’s a point where tragedy strikes and shakes Bob from his addled stupor, but even that isn’t overemphasized as the big turning point that leads him back toward rehabilitation. The case for Drugstore Cowboy as the best film about drug addiction is made through many subtle pieces of evidence, each accumulating into a pointillist slice-of-life that feels absolutely true to these characters and to the mindsets and realities of others like them. At rehab, Bob confesses simply: “I’m a junkie. I like drugs. I like the whole lifestyle. But it just didn’t pay off.” He’s not alone.