Ah, motherhood.

Diablo Cody’s screenwriting career started with a pregnant teenager named Juno. She returns to the subject of maternity with “Tully,” but there’s a crucial difference this time: Cody has three kids of her own now, an experience that informs her painfully funny and sympathetic portrait of postpartum exhaustion. She’s reunited with “Juno” director Jason Reitman, and with Charlize Theron, who starred in the Cody/Reitman joint “Young Adult” (2011), which I don’t think I fully appreciated at the time. These three — the writer, her avatar, and her director — are a formidable team of dark comedians who understand human nature.

Theron plays Marlo, wife of Drew (Ron Livingston) and mother of 8-year-old Sarah (Lia Frankland) and 5-year-old Jonah (Asher Miles Fallica), the latter of whom is probably on the autism spectrum but has so far only been diagnosed as “quirky,” a term that annoys Marlo. (“Do I have a kid or a f****** ukulele?!”) We don’t know what Marlo is like normally because she’s nine months pregnant when we meet her, but we understand she went through a period of depression after Jonah was born; that the new baby was unplanned; and that she’s already tired. (I’ve never been a new mother, but I suspect those who have will see themselves in Marlo.)

As a gift, Marlo’s well-to-do brother, Craig (Mark Duplass), hires her a night nanny, which is exactly what it sounds like: a nanny who only works nights, letting mommy sleep and waking her only when the baby needs to feed. The nanny, a free-spirited 26-year-old named Tully (Mackenzie Davis, all rainbows), proves to be a godsend, not just tending to baby Mia in the wee hours but also cleaning the house and making cupcakes for Jonah’s class. Wary at first of letting a stranger into the home to bond with her baby, Marlo comes to see Tully as a confidante. She even helps Marlo and Drew spice things up in the bedroom!

Reitman uses a montage to show Marlo’s zombified state before Tully arrives — the feedings, the changings, the stained clothes, the lying on the couch eating microwave nachos and watching “Gigolos” — and generally maintains a light directorial touch. Theron commits to the physicality of the role, her body appropriately un-toned and sloppy, bags under her eyes as she trades barbs with Jonah’s principal (Gameela Wright) and contends with the other difficulties in her life. Marlo is weary, but she’s also funny, and Cody finds abundant knowing humor in the situation without resorting to parenting cliches or falling back on self-consciously clever dialogue. She also explores the darker, sadder part of maternity very thoughtfully before coming to the happy ending foretold by the appearance of the Mary Poppins figure. As is often the case, the strange newcomer helps the medicine go down, but the power to overcome life’s challenges was inside us all along.

Crooked Marquee

B+ (1 hr., 36 min.; R, about 15 F-bombs, some mild sexuality.)