It’s not easy to put a new spin on a story that’s been done many times, but British writer/director Joe Cornish finds a way in “The Kid Who Would Be King.”

It’s been eight years since his directorial debut, “Attack the Block,” a ferociously funny and fresh alien invasion flick that succeeded because it’s rooted in contemporary culture — the kids battling the wild extraterrestrials were council estate (a form of British public housing) hoodies. In this, his long awaited sophomore effort, Cornish remains rooted in culture. His heroes may be a bit younger, and he swaps sci-fi/horror for historical fantasy, but Cornish fully embraces the legends and lore that shaped Britain.

If you’re wondering about the challenges he faced in reworking the legend of King Arthur and the Knights of the Round Table, just ask Guy Ritchie, whose “King Arthur: Legend of the Sword” tanked badly at the box office two years ago. But with earnestness and a deep affection for the morals contained within the legend, Cornish crafts a King Arthur movie that promises to draw in a younger crowd, reinterprets the tale for a modern age and speaks consciously to the current political climate surrounding Brexit. That’s quite the feat.

Louis Ashbourne Serkis stars as Alex, a sweet, nerdy kid who bravely sticks up for his best friend, Bedders (Dean Chaumoo), against brutal school bullies Kaye (Rhianna Dorris) and Lance (Tom Taylor). Running from his tormentors, he escapes into a construction site and finds a sword buried in a concrete piling. He pulls it out and discovers that it’s Excalibur, the magical sword of King Arthur.

In short order, the legendary wizard Merlin — in young form (Angus Imrie), older form (Patrick Stewart) and avian form — arrives to guide Alex on his quest to save a leaderless, hopeless, divided Britain.

Alex needs some knights, so he taps Bedders, Lance and Kaye, hoping to rely on their strength and confidence. They realize that this isn’t just make-believe when they witness one of the fiery zombie knights that come for him at night, sent by the witchy villainess Morgana (Rebecca Ferguson), Arthur’s half-sister, who believes the sword is her inheritance.

The quartet sets out on a journey to save the world, learning lessons about what it means to uphold the chivalric code in their actions and in their hearts. This is a smart and sprightly kids’ movie imbued with pertinent lessons, not just about history, but about how we can comport ourselves to be better citizens with honesty, bravery, love and teamwork.

It is a truly epic adventure, and it takes its time traveling from beat to beat. All the story points and emotional journeys are carefully articulated, but the film is far too long — there are anticlimactic climaxes that lead into further battles, and the two-hour running time is unnecessarily protracted, especially for a young audience.

But it’s hard to find fault when the characters are so charming, especially Imrie as a truly wacky version of a teenage Merlin, sporting a baggy Led Zeppelin T-shirt and gobbling fried chicken when he’s not mumbling incantations. Imrie lights up the screen, but Serkis and Chaumoo bring the heart and humor as the best friends who become unlikely heroes.

As a result, “The Kid Who Would Be King” pulls off the difficult hat trick of being simultaneously clever, inspiring and relevant, and that’s worth cheering.