“X-Men: Apocalypse” is a dense, complicated film with a massive cast, numerous locales and probably way too many plot lines.

But as the previous installment of the mutant franchise, “X-Men: Days of Future Past,” taught us, director Bryan Singer and writer Simon Kinberg excel at turning what should be a confusing mess into a compelling, action-packed narrative.

“X-Men: Apocalypse” begins in ancient Egypt where a powerful mutant is going though some process — it’s best not to think too hard about it — when it goes awry and he’s buried under tons of rubble.

Flash forward to 1983 and this guy, Apocalypse (Oscar Isaac, also buried, but under tons of make up) is accidentally woken up and seeks to pursue the usual destroy-the-world routine.

Apocalypse’s evil machinations entail putting together his four horsemen, where he takes mutants — Storm (Alexandra Shipp), Psylocke (Olivia Munn), Angel (Ben Hardy) and Magneto (Michael Fassbender, powerful as usual) — and amps up their powers to help him achieve his goal.

This should come as no surprise, but it’s up to the X-Men to save the day. And there is an abundance of X-Men here. In addition to the crew from the past films — Professor Charles Xavier (James McAvoy), Beast (Nicholas Hoult), Havok (Alex Till) and Quicksilver (Evan Peters) — there are a slew of newbies. The key ones are Cyclops (Tye Sheridan), Jean Grey (Sophie Turner) and Nightcrawler (Kodi Smit-McPhee). And, of course, wild card Mystique (Jennifer Lawrence) is still very involved as well.

That’s a lot of mutants! But somehow it all comes together and even finds a way to build strong character moments.

Singer keeps the film moving like a tensely plotted spy thriller. It jumps around the world with each step adding to the narrative.

It’s ludicrous, overfilled and even sometimes funny. And miraculously, it works.