There’s a fertile, funny idea in “The World’s End,” the new British comedy from the team behind “Shaun of the Dead” and “Hot Fuzz.” Trouble is the idea doesn’t realize its potential until far into the movie.

When the movie’s humor seeds do sprout, they burst in a riotous rush and push. Much beer is consumed. Many fights ensue. Heads get cracked. It’s wild fun — for a bit. But then it fizzles.

“The World’s End’s” prelude to its central idea, a marathon pub crawl by five old friends, consists of ringleader and instigator Gary King (Simon Pegg) recruiting his old school chums for the purpose of drinking at least one pint of beer at every pub on the Golden Mile in their hometown of Newton Haven.

From the instant Gary appears on screen, he’s thoroughly annoying. It’s a wonder his friends open their doors for him. And this early part of the movie feels longer than it is. That’s generally true, too, of the whole movie, which runs an hour and 49 minutes.

Against the odds and against his friends’ better judgment, Gary’s mates agree to his proposal. These five guys, all in their early 40s, tried to do the Golden Mile marathon back in June 1990, the year they graduated from high school. Their first attempt failed, but it still was great fun.

Gary, floundering middle-aged alcoholic that he is, sees the long-delayed conquest of the Golden Mile as the grabbing of a golden ring or a sort of confirmation of his worth, a sign that he’s not a waste of human being after all. He’s really passionate about his quest. It becomes his single-minded obsession.

A hurried voiceover by Pegg during a prologue depicting the guys in their youth offers a quick history of Gary and his friends. Gary once was a big man on his school campus, a legendary partier. But it turned out that the best day of his life was the day he and his mates made their first try at the Golden Mile.

Gary kept drinking after graduation. His choice eventually landed him in a mental hospital. His friends, on the other hand, made proper lives for themselves. Their respectable jobs include real estate agent, car salesman and construction firm owner.

Yet the persuasive Gary lures them back to his misbegotten orbit. Again pursuing beer-fueled glory, the lads quickly get down to business upon their return to Newton Haven, a town whose only claim to fame is being the first place in the U.K. to build a roundabout, circa 1909.

Things soon turn weird for these former residents. They notice there is something different about the town. People there look the same yet they’re not the same.

“The World’s End,” following much screen time during which the movie goes nowhere, turns suddenly, audaciously entertaining. Defending themselves, Gary, Andy (Nick Frost), Steven (Paddy Considine), Oliver (Martin Freeman) and Peter (Eddie Marsan) bash the stuffings out of a throng of strangely aggressive townsfolk. The guys run for their lives on the Golden Mile.

The sources for “The World’s End’s” fun include the 1960 horror-sci-fi classic, “Village of the Damned.” In rare instances, the comedy re-creates the latter British film’s creepiness. The story also gets mileage from the inclusion of Oliver’s sister, Sam (Rosamund Pike). Looking fine at 40, she rekindles old flames.

But “The World’s End” doesn’t end well. After briefly catching comic lightning, the fun fades. Actor-screenwriter Pegg and director-screenwriter Edgar Wright paint their characters into a corner from which they cannot escape.