Rian Johnson’s Star Wars: The Last Jedi, the eighth installment in the venerable, now-four-decades-old space-fantasy franchise, is a big, messy, uneven, but largely enjoyable follow-up to J.J. Abrams’s Star Wars: The Force Awakens (2015), which kick-started the new trilogy in grand fashion largely by returning to what worked in George Lucas’s 1977 original (to the point of following plot beats and themes in a manner than some felt was a bit too derivative). The Last Jedi does something similar, drawing heavily from the plot mechanics of The Empire Strikes Back (1980), which dispersed its cast of characters and sent them on parallel journeys of self-discovery that mined new depths in their various relationships while revealing others that, at the time, we couldn’t have imagined were in store.

Johnson, whose most recent film was the sci-fi thriller Looper (2012), but whose greatest accomplishment was his debut indie Brick (2005), which somehow merged the dialogue of ’40s film noir with a present-day high school setting, draws from Empire’s vast visual iconography and narrative structure (both are essentially extended chase films). Yet, as Abrams did two years ago, Johnson, who both wrote and directed, invests the material with his own sensibility and builds in enough twists that the old feels new. He has some genuinely brilliant visual ideas, one of the best being his staging the film’s climactic battle on a desolate salt flat whose glistening top layer of white when scraped away reveals a scarlet substrata that leaves us with the impression of copious bloodshed. Sometimes, however, his proclivities come at the film’s expense, such as his penchant for inserting quippy humor, sarcasm, and sight gags at odd times, which often undercuts the drama or simply smacks of too much effort. However, when he gets down to brass tacks and lets the drama unfold, he produces some of the most powerful and engaging sequences in any Star Wars film. The Last Jedi is not the best entry in the Star Wars franchise, but parts of it rank at the very top.

The story picks up right where The Force Awakens left off, although Johnson makes the canny choice to make us wait a while before we what happens after would-be Jedi protagonist Rey (Daisy Ridley), having tracked down the legendary Jedi Master-turned-hermit Luke Skywalker (Mark Hammill), presents him with his lightsaber. Instead, the lengthy opening sequence shows how the remaining members of the scrappy Rebellion, led by General Leia (Carrie Fisher), are having to evacuate their base and flee from the fascistic First Order and its gnarled Supreme Leader Snoke (Andy Serkis), who is mentor to Kylo Ren (Adam Driver), the son of Han Solo and Leia who turned to the Dark Side after Luke failed him in his Jedi training. Despite maverick pilot Poe Dameron (Oscar Isaac) successfully leading an attack on the First Order’s most destructive ship, the losses are great and things are looking quite desperate.

We then pick up with Luke, whose response to Rey’s grand gesture with the lightsaber is both surprising and one of the film’s first missteps; what he does makes sense, but the surprisingly comic manner in which he does it, which is clearly meant to humorously undercut two years of fan expectations, feels both dramatically out of sync and a bit glib. Rey is desperate to recruit Luke out of his self-imposed exile to help the Rebellion, but Luke, still disillusioned by his failure with Kylo Ren, refuses to engage her. He is clearly a damaged soul, so broken by the failures of the past that he has come to the conclusion that he should literally be the “last Jedi” of the title. Alas, Rey manages to break through enough of his hardened defenses—such the opposite of the wide-eyed, anxious farm boy we met back in 1977—that he agrees to train her. That training is disrupted when Luke discovers how powerful Rey can be and that she has a psychic connection with Kylo Ren that puts her in the same position that he held decades ago vis-à-vis Dark Vader—intent that he is not purely evil, but rather a conflicted soul who can be brought back from the Dark Side.

Despite the Rey-Luke drama, the first half of The Last Jedi is its most lumbering and uneven, never really clicking as it rambles through its multiple plotlines in a manner that feels simultaneously rushed and overlong. This portion of the film is also saddled with a subplot involving Finn (John Boyega), the conscientious Storm Trooper-turned-Rebel hero who seemed all but dead at the end of The Force Awakens, and Rose Tico (Kelly Marie Tran), a Rebel mechanic who first idolizes him and then joins him on the seemingly impossible mission of tracking down a master codebreaker to help them sneak onto one of the First Order’s ships and disable their tracking system.

However, about midway through the story we get a stunning sequence in which Rey, convinced that she can turn Kylo Ren from the Dark Side, allows herself to be captured by the First Order, which leads to Kylo taking her to face Snoke. At first it feels like little more than a riff on the climax of Return of the Jedi (1983) in which Luke squares off against the Emperor and Darth Vader, but Johnson has a number of twists up his sleeve that turn the sequence into a sustained and constantly surprising series of revelations that thrust the story into an entirely new direction. Unfolding in a massive throne room with red-lit walls lined with faceless scarlet guards (it looks like an experimental theater stage), this sequence is the film’s delirious high point, both emotionally and aesthetically. And everything that follows is almost as good, which helps the second half of The Last Jedi almost live up to the impossible expectations that have been heaped on it for the past two years.