The “hotshots,” the name for a specially trained corps of firefighters, in “Only the Brave.” (SONY PICTURES ENTERTAINMENT/SONY PICTURES ENTERTAINMENT)

As if on cue, "Only the Brave" — a deeply moving drama about firefighters — arrives in theaters, just as the catastrophic wildfires in Northern California seem to be winding down.

Directed by Joseph Kosinski, from a screenplay by Ken Nolan and Eric Warren Singer, the film is based on a GQ story about the Granite Mountain Hotshots, an elite crew of firefighters who experienced a harrowing tragedy in Yarnell, Ariz., in 2013. If that event doesn't ring a bell, I won't reveal precisely what happened. Although it seems only fair to warn audiences that the outcome isn't a happy one.

Still, there's plenty of joy in this story, which starts out like an underdog sports movie. The firefighting crew in Prescott, Ariz., led by the brooding, rugged Eric Marsh (Josh Brolin), is immensely capable. But because they haven't yet been certified for top-tier "hotshot" status, they're relegated to mopping up the remnants of fires that other, more specialized teams have attacked at the front lines.

Eric is a strategic genius when it comes to fire-suppression tactics that look, to the untrained eye, like random destruction. He even personalizes blazes, referring to one as a "b----" and asking, of another far-off conflagration, "What are you up to?" Although Eric figures out the answer to that rhetorical question, he has no authority to put his plan into motion. When a snobby, dismissive hotshot team takes over and bungles the operation, the collateral damage is a whole town.

Much of "Only the Brave" focuses on the Prescott crew's quest for elite status as emotionally significant subplots bubble up around the edges. These include Eric's sweet but strained relationship with his wife (Jennifer Connelly), a veterinarian who hates playing second fiddle to whatever fire happens to be burning nearby, and the story of Brendan (Miles Teller), a recruit who is struggling to put aside his past as a drug user and petty criminal after his ex-girlfriend gives birth to their daughter.

There's also breathtaking action, of course, broken up by amusing dialogue as the guys rib one another or dissect their romantic conquests. The acting ensemble has a believable, brotherly chemistry, especially Teller and Taylor Kitsch, playing a troublemaker who initially teases Brendan brutally before the two warm up to each other, forming an adorable bond.

Shot by Oscar-winning cinematographer Claudio Miranda, the film captures the stunning and terrible beauty of fire. In one mesmerizing scene, Eric reminisces about an awful inferno in which a bear came running out of the forest — completely engulfed in flames. That haunting image becomes an important metaphor as the story progresses.

Continuing his recent trend of playing kindly, drawling cowboys, Jeff Bridges shows up as the fire chief, a role in which he gets to flex some serious acting muscle. Connelly, likewise, provides an emotional reminder of just how talented she is, losing it in one memorable scene — and inviting the audience to follow suit.

For all the action and emotion, "Only the Brave" is also surprisingly informative for anyone unacquainted with the art of fighting fire, delving not just into methodology but also rivalries between those who battle wildfires and those who put out burning buildings. It also shows how comfortable these men are in extremely dangerous situations. This is a job for real heroes. The reminder of their sacrifice could not come at a more opportune time.

PG-13. At area theaters. Contains deadly fires, some sexual references, strong language and drug use. 134 minutes.