Sometimes it’s the movies that are nearly great, but merely good, that break your heart the most.

Such is the case with The Woman King, Gina Prince-Bythewood’s action-packed historical epic set in the early 1820s in the West African Kingdom of Dahomey (today part of Benin). It is a film designed to inspire audiences and elicit cheers and, by and large, it succeeds. But there are undeniable and frequent moments of woozy disconnect, a square-peg-in-round-hole sensation in which this studio-released picture leaps swiftly from detailing the grim realities of the world’s worst prolonged atrocity—the transatlantic slave trade—to GIF-ready beatdowns. Rarely does a film feature a traumatizing rape scene one minute and killer parkour moves the next.

The kinetic action adventure “The Woman King” is a sweeping entertainment, but it’s also a story of unwavering resistance in front of and behind the camera. The ascendancy of women filmmakers over the past decade is one of the great chapters in movie history, and as women have fought their way back into the field, they have also taken up space — on screens and in minds — long denied them. Their canvases are again as expansive as their desires.

Certainly one of the most expansive of these canvases is “The Woman King,” a drama about the real women soldiers of the precolonial Kingdom of Dahomey in West Africa. Directed by Gina Prince-Bythewood, the movie is filled with palace intrigues, sumptuous ceremonies and stirring battles, and features, as golden-age Hollywood liked to brag, a cast of thousands (or thereabouts!). Yet while it evokes the old-fashioned spectacles the studios habitually turned out long before Marvel, there is no precedent for this one.

The story, as moviemakers also like to say, is “inspired” by real events, which in this case are mind-blowing. The tale is rooted in the women warriors of Dahomey whose exact origins remain obscured by tribal myths and oral traditions as well as the obviously biased, self-serving and at times contradictory accounts of European observers. It’s thought that the warriors emerged in the 17th century, and were part of a heavily female social organization that included lots of wives and his-and-her sides of the palatial compound. (The stronghold was about one-eighth the size of Central Park.)

The wives show up now and again in “The Woman King,” seated and standing in a cloud of regal hauteur. They’re lavishly coifed and luxuriously dressed, and, for the most part, passive, as inert and prettily posed as dolls waiting for someone to play with them. That would be King Ghezo, a young monarch amusingly played by John Boyega, who gives the character the nonchalant imperiousness of a very important person who doesn’t seem to do much other than the most essential thing: hold power. If Ghezo wears the crown lightly it’s only because others do his hard, dirty, sometimes murderous work.

It’s the women warriors who do much of the toughest work, and, of course, are the main attractions, which Prince-Bythewood announces at once. So, after a bit of quick, dutiful place-setting — it’s 1823 — the movie takes flight with a showy battle, a grab-you-by-the-throat entrance that gets the story going and blood flowing, yours included. Led by the battle-scarred General Nanisca (Viola Davis), the women soldiers, their bodies oiled to a high gleam, emerge like hallucinations that Prince-Bythewood makes palpably real. Suddenly, the screen fills with intense movement and by turns soaring and falling bodies.