“A good cop can’t sleep because a piece of the puzzle is missing. A bad cop can’t sleep because his conscience is bothering him.”

So says Ellie Burr (Hilary Swank), a rookie cop in the remote fishing village of Nightmute, Alaska. But she’s quoting the very man she’s talking to, her idol, Will Dormer (Al Pacino), a legendary Los Angeles police detective who in “Insomnia” has come to Alaska to help solve a murder. Now Dormer — whose name is French for “sleep” — cannot sleep, and the question is why.

Oh, the superficial reason makes enough sense: It never gets dark here this time of year. Many people suffer insomnia when they first arrive. But the good cop/bad cop reasons are factors, too. A day after arriving, Dormer accidentally shot and killed his partner (Martin Donovan), who was on the verge of cutting a deal with Internal Affairs to help them prosecute Dormer for previous misdeeds. It was an accident … but a very convenient one, as far as Dormer’s career is concerned.

And pieces of the puzzle are missing. Part of the beauty of this dark, desolate film by Christopher Nolan (who also directed “Memento”) is that the murder mystery is no mystery at all. We learn the identity of the killer fairly early: Walter Finch (Robin Williams). Finch, however, also witnessed Dormer shooting his partner. Subsequently, when Dormer reports that it was the killer who did it, not him, no one has any problem believing that. Since Finch knows the truth, he can blackmail Dormer. And since Dormer wants to avoid being identified as the real shooter — no matter how innocent it was, it’s not going to look good — he may have to go along with Finch’s demands.

An ethically ambiguous protagonist was at the center of Nolan’s “Memento,” too, though fans of that film should not expect a repeat in “Insomnia.” The new film explores different issues and has a more straightforward structure. Nolan has been wise not to pigeonhole himself — except as a reliable, gritty director, which is a fine thing to be known as. “Insomnia” has shades of “Twin Peaks” and “Seven,” and it builds tension with great skill.

Pacino and Williams give steely, strong performances — not the highlight of either career, but worthy additions to their resumes. Pacino has played weary cops before, and morally questionable people before, and Williams’ list of seedy characters is growing fast, much to the delight of those of us who were tired of his cloying save-the-world roles.

“Insomnia” does not end in a very satisfying manner. It answers all the questions, but it doesn’t lead to anything particularly powerful. That may be a small price to pay, though, for a film that is otherwise so gripping and forceful.

B+ (; R, abundant harsh profanity, some strong violence, brief non-sexual nudity.)