Matt Damon and his abs in Elysium.

Writer-director Neill Blomkamp follows up District 9 with another solid sci-fi effort in Elysium, a film that delivers terrific action—along with a reasonable amount of smarts.

Unfortunately, Elysium is also a little on the stupid and illogical side, especially during its ending. Yes, I just complimented the film for being smart—so it’s possible to be both dumb and brilliant in the same movie. (Heck, Guillermo del Toro did just that with his Pacific Rim earlier this summer.)

It’s about 140 years in the future, and man has, not surprisingly, screwed up the planet. It’s one big garbage heap (shades of WALL-E and Idiocracy), and the planet’s wealthy people have abandoned Earth for a bitchin’ space station in the sky.

This space station, Elysium, has everything a rich bitch would want: It’s got mansions, pools, sweet landscaping, 10 different kinds of tacos and, most notably, healing booths. These healing booths don’t just fix a bruised knee or a paper cut: They cure cancer, and can even reconstruct one’s face after it has been blown apart by an explosive.

Matt Damon shaved his head to play Max, an ex-con factory worker who puts together droids that police the decrepit Earth. One morning, he gets sassy with one of these very droids—and gets his arm broken for the effort. Then, while working under the watchful eye of the worst boss ever (William Fichtner, who is earning some cool points back after his dreadful turn in The Lone Ranger), Max microwaves himself and suffers radiation poisoning.

With only five days to live, only one thing can save him: a trip to Elysium.

While Elysium has the healing chambers, the snoots in the sky don’t allow Earth residents to use them—so Max can’t just hop on a space shuttle and get fixed up. After a visit to Spider (Wagner Moura), his former crime boss, Max gets a weaponized skeleton welded to his body (echoes of Robocop) and must agree to download a bunch of secret stuff into his brain in order earn a trip to the space station.

Yes, it’s all a little far-fetched—far-fetched and enjoyable, thanks to a stellar performance from Damon and some of the year’s best special effects. The dirty planet, the pristine space station … it’s all spectacularly done.

Sharlto Copley plays against type as a bad guy who is hunting Max. Copley is many miles away from his affable stooge in District 9; he’s a seriously awful beast here, with a fantastic and crazy accent. Jodie Foster gets some of her best work in years as Delacourt, the defense minister for Elysium. She also has a great accent, and has no problem shooting down ships full of Earth residents who are trying to enter Elysium.

Elysium displays super-cool gadgetry and brainy sci-fi—up until its finale, when the whole thing nearly falls apart. I won’t give away the ending, but it is rather dumb and illogical for a movie that had been so smart. That’s not the only issue: Blomkamp, who had delivered terrific action scenes throughout, settles for frantic Michael Bay-type editing for the final showdown.

Still, Elysium is till well worth your time, and establishes Blomkamp as one of the modern era’s kings of cinematic sci-fi. He gets sole credit for the screenplay, so its combined brilliance and silliness rest entirely in his creative hands.

As for Damon, he looks pretty badass with a steel skeleton grafted to his body and a computer drilled into his head. With this, and his turn in Behind the Candelabra, the actor is having a banner year.

Elysium is playing in theaters across the valley.