Robert M. Sapolsky is that rara avis who's both eminent scientist and elegant prose stylist. Three decades ago, at the ripe old age of 28, he won a MacArthur genius grant before settling into a storied career as neurobiologist and primatologist at Stanford University, conducting field work among baboons in Kenya and publishing books with such whimsical titles as "Why Zebras Don't Get Ulcers" and "The Trouble With Testosterone."

His new book is his magnum opus, but is also strikingly different from his earlier work, veering sharply toward hard science as it looms myriad strands of his ruminations on human behavior. The familiar, enchanting Sapolsky tropes are here — his warm, witty voice, a sleight of hand that unfolds the mysteries of cognition — but "Behave" keeps the bar high.

The book opens with a conceit: Consider a simple, everyday tic — chewing gum, say, or bickering with a spouse — and then pivot backward in time. In the instant before the action, Sapolsky charts the intricate web of neurons as they fire up, the seemingly infinite synapses that spark across the organ's widespread regions. In the hours leading up to the behavior, hormones play a critical role; here Sapolsky offers a tutorial on the waves of hormones that wash over us. Wind the clock back to childhood, and there are environmental factors at work, from affluence to poverty, safe neighborhoods versus violent ones. Wind the clock back to conception, and he plumbs how our DNA, as well as epigenetic components, shape us from day to day, year to year. He dials back even further, probing the dice theory of evolution, lizard brains beneath our mammalian gray matter.

"Behave" sparkles with Sapolsky's droll humor, often found in his many footnotes, or in chapter titles, such as this one on adolescence, "Dude, Where's My Frontal Cortex?" He presents an array of alluring anecdotes, among them researcher Walter Mischel's famous experiment from the 1960s and '70s, in which children of all ages were shown a marshmallow and asked to defer eating it for 15 minutes, with a second marshmallow as a reward for their self-restraint. "Mischel's next step made his studies iconic — he tracked the kids forward, seeing if marshmallow wait time predicted anything about their adulthoods . ... Five-year-old champs at marshmallow patience averaged higher SAT scores in high school (compared with those who couldn't wait). ... Forty years post-marshmallow, they excelled at frontal function, had more PFC [Prefrontal cortex] activation during a frontal task, and had lower BMIs [Body-Mass Indices]. A gazillion-dollar brain scanner doesn't hold more predictive power than one marshmallow."

Stories such as this one infuse charm and élan into the book's complex, frequently dense narrative, illuminating the brain in unprecedented ways. Welcome, then, a stunning achievement and an invaluable addition to the canon of scientific literature, certain to kindle debate for years to come.

Hamilton Cain is the author of "This Boy's Faith: Notes From a Southern Baptist Upbringing," and a former finalist for a National Magazine Award. He lives in Brooklyn.

Behave: The Biology of Humans at Our Best and Worst
By: Robert M. Sapolsky.
Publisher: Penguin Press, 790 pages, $35.