Many would say that Martin Scorsese’s The Departed is a classic, or at least rewatchable. I’ve always thought it felt like the work of a great artist chasing past glories and never quite catching up to himself. “I don’t want to be a product of my environment. I want my environment to be a product of me,” growls Jack Nicholson’s Boston mob boss Frank Costello in the fllm’s opening moments, neatly summing up my problem with a Best Picture winner that’s made up of bits and pieces of its superior predecessors. A jacked-up Rolling Stones music cue here; an unexpected kill shot there; and a pinch of tortured Catholicism for that personal touch. Except that between its borrowed Chinese source material (check out Infernal Affairs, if you haven’t) and the strangely generic staging of most of its shootouts and shouting matches, The Departed actually feels weirdly impersonal. Mean Streets and Taxi Driver weighed the wages of sin, but The Departed’s carnage is weirdly weightless. It’s a morality play like Goodfellas, but its cartoon gangsters have no souls to sell in the first place.

I’m just going to say it: The better mid-2000s Mark Wahlberg cop movie is We Own the Night, which arrived on Netflix this week and is not only rewatchable but revelatory. For my money it’s the best movie by James Gray, an American filmmaker whose reputation at the time of the movie’s release had nowhere to go but up. In 2018, Gray is a critically acclaimed auteur with enough respect to get Brad Pitt to sign on for a 2001-style sci-fi epic. But in 2007, he was mostly seen as a pretender-to-the-post-Pulp-Fiction throne, whose moody, underlit thrillers had earned mostly disparaging comparisons to work by generational peers like Paul Thomas Anderson, David Fincher, and the ’70s masters he was obviously trying to evoke like Francis Ford Coppola, William Friedkin, and, of course, Scorsese. The latter’s shadow loomed particularly large over Gray’s early works Little Odessa and The Yards.

Debuting at Cannes a couple of months after The Departed’s Oscar triumph, We Own the Night was booed there by American critics and dismissed as derivative once it finally made it to theaters that fall. In the year of No Country for Old Men, There Will Be Blood, and Zodiac, Gray’s superb but underpromoted and commercially underperforming movie didn’t make much of a dent in the cinematic consciousness.

The movie is about fate,” Gray told The New York Times, suggesting a theme that’s superficially similar to, but tonally quite distinct from, The Departed’s. Both films deal with people infiltrating dangerous underworlds. The characters, played by Leonardo DiCaprio (in The Departed) and Joaquin Phoenix (in We Own the Night) both have to hide their police affiliations from mobsters who’d kill them if they knew the truth. Where Scorsese plays his story of a deep-cover agent in over his head for suspense and comedy, Gray uses it to lay the foundations of a tragedy that’s no less powerful for its intimate, individual scale.

As the film begins, Phoenix’s Bobby Green, who manages a Brighton Beach nightclub with a shady clientele, is a black sheep boy whose joy for living is unbridled. The opening smash cut to him staring at his girlfriend, Amada (Eva Mendes), to the sounds of Blondie’s “Heart of Glass” is exciting and erotic in a way that not only evokes Scorsese at his best but tops The Departed’s strained “Gimme Shelter” overture in terms of pop foreshadowing.

Riding high on love’s true-bluish light,” coos Debbie Harry in the best song she ever wrote or sang. The tragedy of Gray’s film lies in how its harmless outlaw hero ends up losing everything he loves on the right side of the thin blue line. As spectacular as Phoenix has been in his collaborations with PTA and Lynne Ramsay, I’d say his performance in We Own the Night is his best—or at least his most emotionally affecting—because of how skillfully he portrays a character gradually being drained of his life force. The wary, resentful distance Bobby keeps from his father, Burt (Robert Duvall), and brother, Joseph (Wahlberg), both decorated NYPD officers who look down on his illegal dealings, becomes collapsed as the Russian drug dealers being pursued by the latter (and who frequently patronize Bobby’s club) keep escalating the terms of their battle against the police.

“Eventually, you’re going to be with us or with them,” says Duvall’s law-abiding patriarch early on, stoking our expectations that his prodigal son will return to the fold. He does, and therein lies We Own the Night’s unique and audacious sense of tragedy. By all moral and narrative logic, we should cheer as Bobby gradually embraces his uniformed birthright, snapping into action after assassination attempts against his kin, and letting himself be used as an undercover asset against his benefactors, who are never shown to be sympathetic or sentimental. These Russians, who control Brooklyn’s coke trade, are scary dudes. But Gray’s subversiveness comes through in his vision of the NYPD as its own kind of cabal, bound by suffocating family ties and tribal, territorial ideas of loyalty that strip initiates of their individuality.

The film plays as if Michael Corleone’s great line in The Godfather Part III had been spun 180 degrees on its axis: Just when Bobby thought he was out, the cops pull him back in.

This is complex stuff, and Gray gives it a sense of gravity that comes through not only in the acting—with Phoenix’s increasingly heavy-souled performance anchoring things in nearly every shot—but also the filmmaking, which is virtuoso in a grimly stylized sort of way. We Own the Night is steeped in the techniques of gangster movies, but it has sequences that vibrate with the terror of great horror cinema, like when Bobby infiltrates a crack house wearing a wire or, later on, attempts to pilot a police convoy in a torrential rainstorm. The first is as tensely pressurized as the botched coke deal in Boogie Nights, but where Anderson can’t help but Tarantino-ize the situation with a cheerfully contrapuntal “Sister Christian” power ballad, Gray opts for an ominous soundtrack rumble, a la David Lynch. As for the car chase, it’s truly nightmarish, using the surrounding downpour to simultaneously obscure and heighten the action, which unfolds not in slow motion but in hypnotically drawn-out real time, accompanied only by shotgun blasts and the metronomic rhythm of windshield wipers.

This scene takes place about two-thirds of the way through the film. Gray doesn’t top it in terms of spectacle, but his climax packs an emotional punch. Actually, it packs two of them. In a late scene, Amada, beautifully played by Mendes—an always-wonderful actress who may also be the female MVP of eccentric and/or underrated modern cop movies (including Bad Lieutenant: Port of Call New Orleans and The Other Guys, where she deserved an Oscar nomination for her achingly beautiful rendition of “Pimps Don’t Cry”)—confronts Bobby about his abandonment of her in favor of his family. It sums up the script’s critique of institutional and hereditary machismo and features a killer Godfather allusion. Instead of having the door slammed on her like Kay at the end of Coppola’s classic, a devastated Amada shuts out Bobby once and for all. (Note that David Chase did the same thing later that year with Dr. Melfi’s farewell to Tony in the penultimate episode of The Sopranos.)

Amada’s heartbreak serves as a prelude to a final scene that’s as carefully measured and deceptively unsettling as any contemporary movie coda that I know. (Gray is great with endings, as evidenced by the sublime optical illusion that concludes The Immigrant and the surreal, haunting outro in The Lost City of Z, both of which elevate the accomplished movies that they’re attached to.)

If We Own the Night’s opening scene carries an electric charge of lust—and more to the point, a lust for life—the closing exchange between two key surviving characters is drenched in embalming fluid. Of all the movies that build up to one person telling another “I love you,” We Own the Night may be the least satisfying. The line, its delivery, and its meaning are as ambiguous as The Departed’s parting shot of a rodent scuttling across the screen is one-dimensionally meaningful (“The rat symbolizes obviousness,” as Ralph Wiggum would say). You can watch The Departed over and over again because all of its myriad betrayals are a setup to a punch line about how we’re all rats in the end. In We Own the Night, it’s loyalty that hurts.