Apart from their brief face-off in Michael Mann’s “Heat” in 1995, Robert De Niro and Al Pacino have never shared the screen, and it would have been better for both their reputations never to have co-starred than to be trapped together in a piece of junk like this lurid, stupid cop melodrama. “Righteous Kill” was written by Russell Gewirtz, whose script for Spike Lee’s “Inside Man” was clever and smart, but here he’s constructed a silly serial killer puzzle that isn’t at all surprising in the end, and is crammed with sequences so overwrought and dialogue so monumentally pseudo-tough as to be absolutely laughable. And it’s directed not by somebody of Lee’s caliber, but by Jon Avnet, the auteur of the recent catastrophe “88 Minutes,” which was notable not only for its gross idiocy but for showcasing probably the worst performance Pacino has ever given.

Perhaps it’s no wonder that given the dreck the celebrated stars had to work with, they manage to produce nothing but crude self-parody. But even though each seems to have entered his hack period—like Sir Laurence Olivier did at the end of his career as he took on parts in movies like “The Boys from Brazil” and “The Betsy”—we might at least have been spared the sight of them chewing the scenery in a single frame barely capable of containing all the ham despite the widescreen format.

De Niro and Pacino play geriatric NYC detectives with the unlikely nicknames of Turk and Rooster on the trail of a vigilante who’s offing scumbags that have cheated the justice system and been loosed again on the world. The killer has the habit of leaving bits of doggerel with the corpses as his signature, earning him the nickname The Poet, though the quality of his literary work is way beneath Ogden Nash on his worst day. From the very beginning we see Turk confessing to the crimes, which means that the ending would be surprising only if he actually turned out to be the killer. He’s not, of course; but the identity of the real gunman is as predictable can be. (No, it’s not Robert Frost.) The only shock comes from the utter preposterousness of his motive.

Folded into this plot is Turk’s romance with a sultry medical examiner (dull Carla Gugino), who grows increasingly suspicious of him, and competition from a younger team of detectives (John Leguizamo and Donnie Wahlberg, both terrible), with whom the old guys fight in the sort of shouting and shoving matches that are bad writers’ idea of how cops interact in New York. A bored Brian Dennehy shows up as the obligatory gruff captain, and Curtis “50 Cent” Jackson makes an appearance as a slick drug kingpin our guys try to trap with the help of a winsome young lawyer (Trilby Glover), confirming that the complete lack of acting ability he demonstrated in “Get Rich or Die Tryin’” was no fluke.

With its ludicrous plot, risible dialogue, crudely overemphatic direction and vulgarly broad performances, “Righteous Kill” might have worked as a comedy, but like “88 Minutes” it’s presented in all seriousness, which makes it all the more hilarious—in the worst sense. It’s a visually ugly movie as well, with coarse, in-your-face cinematography by Denis Lenoir and jumpy editing by Paul Hirsch, appropriately accompanied by a bombastic score from Ed Shearmur.

This is a dispiriting movie that makes it even more difficult to remember that there was a time, long past, when De Niro and Pacino were giving great performances rather than doing embarrassing vaudeville turns. Their ranting here, particularly in their ludicrously overextended final confrontation, makes one of the last lines of dialogue—“We did good”—all the more ridiculous. Far more accurate is what Rooster had opined just seconds before: “This is the bad one.” Indeed.