“Good grief” is a phrase we normally associate with Charlie Brown. But it also applies aptly to Kenneth Lonergan’s majestic “Manchester by the Sea,” a movie so lovely in its tone and texture that it redefines sweet sorrow.

It begins in Quincy, Massachusetts, the city of presidents, and ends farther up the coast on Cape Ann, where cod is king. In between lays millions of gallons of water, none of it under the bridge for Casey Affleck’s zombified Lee Chandler. He’s hurting. You can see it in his dead eyes, as he carries out menial jobs as a live-in janitor/handyman at a Quincy apartment complex. He’s oblivious to the come-ons from the attractive tenants and curt with those who treat him like their flunky. He’s so antisocial, you suspect he’s afflicted with a form of Asperger’s, like brother, Ben, in “The Accountant.”

It’s an assumption well supported by Lee’s seeming indifference when informed that his older brother, Joe (Kyle Chandler), has just succumb to a congenital heart condition, leaving behind a rambunctious teenage son Lee is ill-prepared to parent. But there’s much more to Lee than initially meets the eye, which becomes hauntingly clear over the course of a movie that is ingenious in its depictions and its structure. It’s only Lonergan’s third film after “You Can Count on Me” and “Margaret,” but it exhibits a level of artistry suggesting a master builder.

Where most filmmakers would immediately spell out what’s eating at Lee, Lonergan plays it like a cardsharp, holding his aces and waiting for precisely the right time to lay them down through flashbacks woven delicately into the fabric of a story brimming with humor and heartbreak. And when all the pieces of the puzzle snap into place, it’s devastating. But it’s also rewarding in how reaffirming it is to see a man so utterly defeated by life find hope where and when he least expects.

It’s a lock that Lonergan will pick up an Oscar for a screenplay that thrives on its strong sense of realism and its steadfast refusal to give in to sentimentality. But that doesn’t mean you won’t be deeply moved. You will, and what moves you is how invested you become in the lives of Lee, his nephew, Patrick (Lucas Hedges), and Lee’s equally lost ex-wife, Randi (Michelle Williams).

There are at least a half-dozen scenes that offer a clinic on filmmaking, but the one I can’t shake involves a chance meeting between Lee and Randi in which they tearfully flail at making sense of how their lives have been forever crippled by a single act of negligence. It’s so powerful it could well earn Oscars for both Williams and Affleck. Even if it doesn’t, this will be the film that forever moves Casey out of brother Ben’s enormous shadow. If there was ever any doubt who was the better actor, Casey soundly lays that argument to rest with a performance that inspires awe.

There are so many places that one wrong gesture or line reading could sink the entire enterprise, but Affleck nails it time and again, disappearing so deeply into the role you forget you’re watching a movie. That’s how accurate he renders Lee’s pent-up agony and guilt. Matching him every step is Hedges. They bicker with the gusto of an old married couple, each thinly veiled insult born out of the fear of their uncertain futures. Lee and Patrick don’t necessarily like each other, but deep down they know they need each other to summon the strength to go on. The fact that Lonergan is able to communicate their co-dependence so vividly and affectingly is something you almost never see in movies anymore.

Ditto for “Manchester’s” strong sense of place. It was shot almost entirely on location in Lynn (standing in for Quincy, which is name-dropped quite often), Beverley and Manchester, and it gets everything right, from the people who live there to their devotion to the holy trinity: God, the sea and the Bruins. Lonergan is a native New Yorker, but you’d swear he lived on the North Shore all his life, given the exactness of the vernacular and those often-mutilated Bawston accents. It’s all wonderfully, achingly real. Even Kyle Chandler, who has barely a line of dialogue, is outstanding as both a corpse and a shoulder for Lee to cry on.

You also feel the weight and importance of Chandler’s Joe in scene after scene. He was everything Lee wasn’t: Strong, sensible and sharp, a successful fisherman whose only failing was his drunken ex-wife (Gretchen Mol). Motherhood was never Elise’s thing, and even now as she tries to re-enter Patrick’s life, Mol makes it clear that any further contact with her son would be detrimental. She also helps underscore how much Patrick needs Lee to be his rock. He’s all the kid has left, unless you count the two girlfriends Patrick hilariously tries to juggle between hockey practice and rehearsals with his garage band. And that’s when Affleck is at his finest; letting us see the fight Lee is having with his conscience over whether he can reopen his broken heart to another human being.

It’s an inner turmoil we see about to boil over at any second, often leading to barroom brawls and frustrated admirers who can’t understand why they can’t connect with Lee’s battered soul. Little do they realize that it’s the town and all the pain and sorrow it represents that makes him the way he is. In Quincy, he’s just a face in the crowd. But in his hometown of Manchester, he always a man to either be pitied or reviled. He just wants to forget and no one will let him. We can’t forget, either. Lee is a figure too tragic even for Shakespeare. But his pain, and yes, his courage is seared into our memories, making “Manchester” not just a place by the sea, but also a piece of our hearts.

“Manchester by the Sea”

Cast includes Casey Affleck, Michelle Williams, Kyle Chandler, Lucas Hedges and Gretchen Mol.

(R for language throughout and some sexual content.)

Grade A+