It starts low and tiptoeing, a little tune creeping along in the dark like it's trying not to wake anything. Then it comes round again, slightly faster. Then again, faster still, and louder, and you can feel where this is going long before it gets there. By the end the whole orchestra is hammering the same handful of notes at a pace nobody can keep up, and something has gone very wrong indeed. You've heard it under a chase, under a heist tightening, under a montage where a plan starts to come apart, played for laughs and played dead straight. The name, though, tends to slip away the second the scene ends.

It's called "In the Hall of the Mountain King," and Edvard Grieg wrote it in 1875 for a stage play. One of its eeriest outings is also one of its oldest. In Fritz Lang's "M," from 1931, a child-killer played by Peter Lorre whistles this exact tune as his calling card, and the audience learns to dread it: when the melody drifts in off-screen, he's close. It's one of the first films to use a musical name tag like this, a tune that stands in for a character. The detail that fits this channel best: Lorre couldn't actually whistle, so the director, Fritz Lang, dubbed the whistling himself.

Fritz Lang's "M" (1931) — the killer whistles Grieg

It was written for a man lost in a kingdom of trolls

Grieg wrote it as part of the incidental music for Henrik Ibsen's play "Peer Gynt." In the scene the piece belongs to, Peer has wandered into a mountain kingdom of trolls and tangled himself up with the troll king's daughter. He is somewhere he very much should not be, surrounded by things that are not friendly, and the situation is slowly, then quickly, closing in on him. A man among the trolls, the floor tilting under him.

The structure gives the game away. The tune starts quiet and sneaking, the way you'd move through a hall full of sleeping monsters. It repeats, and each time it comes back it's a touch faster and a touch louder, the trolls waking up, the room filling, the exits closing. By the end it's a frantic, pounding stampede. That isn't a melody that travels somewhere new. It's the same little idea, wound tighter and tighter until it explodes.

Grieg built a machine for tension out of one tune and a steadily turning screw.

Why every film reaches for it when the plan starts to go wrong

Most music has to be coaxed into a scene. This one arrives pre-loaded with a feeling: small thing creeping, getting bigger, getting faster, about to break. Point a camera at a heist where the timing is slipping, a chase where the gap is closing, a montage where confidence curdles into panic, and the music does the work before a line of dialogue lands. It's the sound of a situation getting away from everyone in it. Winding up to chaos, in a couple of minutes, on demand.

So it has gone everywhere, under countless chases and heists and trailers, played dead straight and played for a laugh. Trent Reznor and Atticus Ross reworked it for the Henley rowing scene in "The Social Network," tension and competition and money all tightening at once, on a score that went on to win the Academy Award.

The Social Network (2010) — Reznor & Ross's rework, the rowing scene

There's one use that gives the trolls back their music. In 2016 DreamWorks built the song "Hair Up," from their animated film "Trolls," on the opening notes of the tune, and the wordplay underneath it is deliberate. In the film, "Bergen" is the name of the creatures who hunt the Trolls, and "Bergen" is also the Norwegian word for mountain. Their ruler is King Gristle. So the Mountain King is right there, and the Bergen castle the Trolls have to break into is, quite literally, the halls of the mountain king. Everywhere else the trolls are invisible and only the dread survives the trip to the screen. This is the one time they got their music back.

Trolls (2016) — "Hair Up"

The same music is also a comedy staple

Because the build is so relentless and so obvious, you can play it completely straight or you can play it for a laugh, and it works either way. The winding-up-to-chaos that scores a genuine disaster will, pointed at someone late for a bus or a cartoon character backed into a corner, turn the panic into a joke. The structure doesn't change. Only the camera does. A piece written for a man cornered by actual monsters turns out to be just as good at a man cornered by his own bad morning, and the gap between those two is most of the fun.

Grieg sat down to score a Norwegian fairy-tale nightmare for a play, with no chase scene or sight gag anywhere in his mind. He built a perfect engine for "this is about to go very wrong," and once the world had it, the world used it for every kind of going-wrong there is, terror and farce and everything between, without changing a note. The trolls left. The pressure stayed.

Follow the creep to the stampede

If "In the Hall of the Mountain King" has only ever reached you under a chase or a punchline, what you carry around is a fragment cut to length for somebody else's scene. It's a short piece, it ends fast, and the version lodged in your head is probably a few seconds grabbed for a trailer. Heard whole, in its place, with the creep and the climax intact, it's stranger and better than the snippet.

It's on the Essential Classics channel below, sitting at the end of a full run of Grieg's "Peer Gynt" and the Piano Concerto, so once the mountain king has had his moment there's a whole evening of that world on either side of it. The clip drops you straight onto the piece, the creeping opening the first thing you hear. Press play, let the tune start its slow creep, and follow it all the way up to the stampede.

Peer Gynt — Edvard Grieg (Essential Classics)

The rest of Grieg is one channel away, and so is the next composer the movies have been quietly borrowing from for a hundred years. The next time a tune starts tiptoeing up toward chaos, you can tell the room it's really a man lost among the trolls.