M. Night Shyamalan has had a roller-coaster career, quickly reaching the heights with “The Sixth Sense,” “Unbreakable” and “Signs” but then going into precipitous decline with “The Village,” “Lady in the Water” and “The Happening”—in which the trap he had made for himself, of promising a stunning twist ending, really worked against him: he was bound to disappoint. His effort to rehabilitate his reputation with more conventional fare—“The Last Airbender” and “After Earth”—turned out terribly, and though “The Visit” represented a comeback of sorts, it was a modest one.

Now with “Split” he goes for the gold, aiming essentially for another roundhouse punch, one that will appeal to a wide audience looking for rather cheap thrills while offering a special gift to fans who have stayed with him through all the stumbles—in the form of a last act that links up with one of his early films, topped by a flourish that isn’t so much a twist as a semi-promise of a sequel. The key to what success the film has, however, isn’t so much Shyamalan’s contribution, which amounts to a script that caps a rather unsavory premise with a finale that lapses into goofiness and a directorial style that’s characteristically stilted, but a flamboyant lead performance by James McAvoy.

McAvoy plays a young man named Kevin Wendell, or at least mostly named Kevin. That’s because he suffers from multiple personality disorder, or if you prefer dissociative personality disorder, and switches from one persona to another with startling speed. He comes to his therapist Dr. Karen Fletcher (Betty Buckley) as Barry, an over-the-top fashion designer, but though remarkably sympathetic (since Kevin provides her with the prime example of some radical ideas she’s developed about multiple personalities) she begins to suspect that something has gone awry with her patient.

As it turns out, she’s right. The film has already shown Kevin, in another personality—of a preternaturally prim, efficient fellow whose name is later revealed as Dennis—abducting three teen girls—popular Claire (Haley Lu Richardson) and Marcia (Jessica Sula) along with their saturnine friend Casey (Anya Taylor-Joy). He imprisons them in some sort of underground bunker, where he will soon visit them as some of his alternate personalities—a schoolmarmish woman named Patricia, but especially a nine-year old boy named Hedwig, who loves to add “et cetera” to every other sentence.

Much of what follows involves the girls’ efforts to escape, which will result in each of them being locked up alone. The focus, however, is on gloomy Casey, and on the reason for her dour attitude: flashbacks to her childhood (with Izzie Coffey as the five-year old tyke) illustrate an extremely unhealthy relationship with her Uncle John (Brad William Henke), who became her guardian after the untimely death of her loving father (Sebastian Arcelus), with whom she used to go out deer hunting. Accustomed to dealing with dangerously unpredictable people with power over her, only she has the smarts that might enable her to survive.

The juxtaposed sequences of the multiple Kevin personalities interacting with the girls and Barry conversing with Fletcher ultimately lead to the revelation that among Wendell’s twenty-three identified personalities, Dennis and Patricia had supposedly been banished from the light—that is, prohibited from emerging and taking over. That’s obviously not the case. Even more menacing, those two personas are predicting the arrival of a twenty-fourth, a figure simply called The Beast.

It wouldn’t be fair to reveal how Shyamalan works out this scenario, but one can say that he ties together Kevin’s story with Casey’s past in a fairly canny fashion, and that the narrative borrows some of its beats from “Psycho” and “The Shining,” among other pictures, along the way. The portions of the picture dealing with Kevin and the kidnapped girls, however, grow increasingly unpleasant as the tale progresses, and in them the director seems to be slumming a bit.

But however implausible the tale becomes—and in the last twenty minutes it goes bonkers, unless you’re a comic-book fan–it’s impossible to take your eyes off McAvoy. His ability to take on Kevin’s different guises, often from one frame to the next, is a virtuoso achievement—not great acting, perhaps (any more than Rod Steiger’s impersonations in “No Way to Treat a Lady” constituted great acting), but enormous fun to watch. Otherwise the performances are basically serviceable, with Taylor-Joy fine but hardly exceptional as the troubled victim whose problems won’t be resolved even if she survives her current predicament. As usual, Shyamalan pops up in a cameo, as does another recognizable face.

“Split” is reasonably stylish for a low-budget film, with Mara LePere-Schloop contributing a convincing production design, while cinematographer Mike Gioulakis and editor Luke Franco Ciarrrocchi work closely with the director to maintain the cool, detached, even stately mood he favors.

In sum, Shyamalan has made a horror movie that’s cleverer than most, though not nearly as mind-blowing as his fervent admirers will claim.

But it sure beats “Lady in the Water.”