MIAMI — It had just finished raining, in that swift and furious Miami way, and the director Barry Jenkins and the playwright Tarell Alvin McCraney were heading through the Liberty Square housing projects.

The two men strolled past crumpled snack wrappers and empty Olde English beer cans, broken toys and charcoal-colored rat traps. Then Mr. Jenkins stepped onto the patchy grass of the courtyard that sits between a grouping of desperate-looking buildings, low-slung and austere, the type of stingy architecture we’ve come to equate with housing for the poor. He stopped, raised his arms and spread them wide.

“This is the world of ‘Moonlight,’” he said, smiling, referring to their widely acclaimed film. “It’s beautiful, right? When the sun comes out, it just pops.”

Mr. McCraney nodded. “It is the confluence of madness and urban blight,” he said. “Yet, it is incredibly beautiful. It is still a neighborhood.”

We paused then, and quietly, slowly, looked around. And because the men were being earnest, in that moment, I saw it, too.

To someone for whom Miami is the gaudy, palm-tree-and-Art-Deco opulence of South Beach, the poverty of the Liberty City neighborhood, and its Liberty Square public housing projects, would be jarring. But amid the heavily wired windows and dingy facades, some families wrapped their doors with Christmas paper and bows, and holiday lights blinked along window frames. Clothes hung from lines flapped and danced in the wind. Little girls with brightly colored barrettes in their hair skipped along the sidewalk.

This is the neighborhood where the two men were raised, coming of age during the crack epidemic of the 1980s and ’90s. The men did not meet until they were adults, but when Mr. McCraney, 36, and Mr. Jenkins, 37, teamed up to make “Moonlight,” they saw the story — about a boy with an addicted mother, who grows up struggling to understand what it means to be gay — through the same eyes.

Barry Jenkins is compact, bald, bespectacled and bookishly handsome. Tarell Alvin McCraney is much taller, with an immaculately groomed beard and stylish green Adidas sneakers — handsome, too, but in a more striking way. Mr. Jenkins is straight; Mr. McCraney said he considers himself “gay-identified.”

Yet their childhood experiences were so similar, their lives so parallel, that you could mix up many facts of their biographies and they’d still be true.

Liberty City, one of the poorest sections of Miami and almost entirely black, is geographically tiny, little more than the housing projects and the blocks surrounding them. But it is also tiny in that particular way that poverty and extreme racial isolation build formidable, and virtually unscalable, walls. Liberty City was not just their neighborhood. It was their universe.

Both men were born to mothers who had their first children when they were teenagers. Both saw their mothers become H.I.V. positive after falling victim to the crack epidemic that overtook their community. Both were taken away from their mothers and bounced around; caregivers, related and not, took them in. They both knew what it was like to have the water turned off for lack of payment, to go to school without deodorant because there was no money to buy it.

Yet their family members, including their mothers, pushed school and a love of reading; their neighbors and educators fought for them and encouraged their talents. The Liberty City of their childhood was at once a place that buckled under the rages of crack but also, defiantly, maintained a cultural richness and sense of community that nurtured and inspired the two men — it was a place that both contained and freed them. And it is the way that “Moonlight” captures that tension — between the beauty and the struggle — that makes the film so powerful.

Writing to Process the Pain

When Mr. McCraney wrote the screenplay, it was 2003. He had just graduated from DePaul University in Chicago and was headed to the Yale University School of Drama (where he would later graduate with a master’s and was recently named chairman of playwriting).

Then his mother died of AIDS. She had gotten clean by then, but there was no reconciliation like the one that plays out in the movie between Chiron, the main character, and his mother.

“Since 13, I’ve kind of been wading through that water and finally, to get to the arrival of her death, was sort of surprisingly calm,” he said. “But then, I started to continuously have these memories, thoughts of growing up in Miami and my mother in that time. I had bad guilt for not being at her bedside when she died, terrible guilt about not asking her the questions you always regret not asking your parents when they pass away.”

Mr. McCraney did what he’d always done to process his pain. “I just started writing those thoughts down,” he said. “I was a 22-year-old mourner. I was crying my way through it.”

Though he’d never written a screenplay, Mr. McCraney knew this story was meant to be a movie. He named it “In Moonlight Black Boys Look Blue,” and then it sat for nearly 10 years, until a mutual friend from the Miami drama scene emailed the script to Mr. Jenkins. The friend couldn’t believe the paths of the men had not yet crossed.

Though they would not realize it until a few weeks ago — when on a ride to Liberty City, Mr. Jenkins searched his email — that fortuitous script landed in his inbox on Oct. 17, 2011, Mr. McCraney’s 31st birthday.

Mr. Jenkins, after making his first film six years earlier, had been trying to figure out his next project and felt that it should be something personal. He’d written a film treatment that would tell the story of his growing up in Miami.

Image

Naomie Harris in “Moonlight.”CreditA24

“It was about my mom, and then I was like: ‘Ugh, nah, it’s too personal. I don’t want to make that,’” Mr. Jenkins said. What attracted him to Mr. McCraney’s screenplay was that the story was so close to his own, yet not his own.

Mr. Jenkins wanted the playwright to rework the script. But Mr. McCraney was too busy. He had just won a MacArthur fellowship, known as a genius award — something Mr. Jenkins teases mercilessly, shouting, “There’s the genius!” when seeing him.

A few years passed, and finally, Mr. Jenkins decided to try to adapt the screenplay on his own. James Baldwin once wrote: “All art is a kind of confession, more or less oblique. All artists, if they are to survive, are forced, at last, to tell the whole story, to vomit the anguish up.” And, it was through the rewriting that Mr. Jenkins realized he had been fooling himself.

“I thought I could hide behind Tarell in this piece, thinking, ‘This is personal for this cat; it’s not personal for me,’” Mr. Jenkins said. “I was wrong.”

Parts of the movie clearly tell Mr. McCraney’s story. It was Mr. McCraney who was horribly bullied, often physically.

There is a scene when a bully instigates a group beating of Chiron, who returns the next day and breaks a chair over the bully’s back. As we walk by the middle school that inspired this moment, Mr. McCraney points out the spot on the second floor where he would stand, peering fearfully at his tormentors waiting for him outside. He never hit a bully with a chair, he said, but “I did snap.”

He will not tell me how, exactly: “Let’s not talk about it.” But he said that to this day, he has nightmares that he did not graduate eighth grade, that he is stuck there with them.

Still, so much of Mr. McCraney’s story was Mr. Jenkins’s story, too — the terror and instability of the crack years, the mother who could sell the family TV but who also exposed her son to books. (In the playwright’s case, reading to him all 1,100-pages of Stephen King’s “It.”) The two developed a deep bond over the brokenness, and the inability to trust, that they still feel.

Directing “Moonlight,” Mr. Jenkins said, “was very visceral, like working an open wound.”

The artists hold closely idyllic memories of Liberty City before crack. It was poor and disregarded, yet full of little joys. As kids, they had for a time attended the same elementary school. They frequented the same mini mart where Mr. Jenkins would be sent to buy Benson & Hedges menthols for the woman he called Grandma.

They remember the same swinging tree, dancing at jams held in the amphitheater, and the annual turkey bowl when neighbor kids would gather in the green space between buildings to play football on Thanksgiving.

Image

Mr. McCraney, left, at 5 or 6 on the Sunday of his baptism and Mr. Jenkins in first grade.

Their memories unknowingly reflect Liberty Square’s original idealism when it opened in 1937. One of the first federal public housing projects for black people, Liberty Square had indoor plumbing and electricity — a rarity — and attracted middle-class strivers who had been hemmed into substandard segregated neighborhoods. The community was proud and close-knit, though it was literally walled off from a white neighborhood by a concrete border.

And then, as is the history of this country, Liberty City was sabotaged by racist urban renewal policy and official neglect. The city rammed an Interstate through a nearby low-income black neighborhood, displacing those residents and flooding Liberty City with poverty and few resources to deal with it. Riots in 1968 and 1980 further decimated their community. Businesses fled, as did much of the black middle class, leaving behind those with no resources to go.

The crack epidemic, when it swept in, took advantage of a place already made vulnerable. Where the community’s smallness once felt like an embrace, now it felt like suffocation.

“Very, very slowly certain areas of the neighborhood began to be off limits,” Mr. Jenkins said. “I just remember this moment where it went from being this thing where you could wander anywhere, almost like Huck Finn, to places you had to avoid.”

Mr. McCraney recalls when the amphitheater was no longer a place of dance parties, but of vials cracking under your feet. “I remember seeing all these black bodies sort of laying around, and it had become like a crack den,” he said. “I remember there was an older guy who was like: ‘Get out of here. Don’t come back here. Don’t play over here.’”

But Mr. McCraney also talks about the resiliency of the children, how they would escape by making up games and songs and stories. “We sort of found a narrative that allowed us to still have an imagination and grow within that atmosphere, which I found and still find incredibly inspiring.”

It is no accident that in casting for “Moonlight,” Mr. Jenkins picked the little boys who play Chiron, and Chiron’s friend Kevin, from a Miami middle school that resembled the ones they attended.

This connection to, this understanding of, Liberty City is clear in each frame of the movie, in the way that the characters subtly rebuke every stereotype we’ve seen of the crack-addicted black mother and the drug-dealing black man.

“My mom went through so many things,” Mr. Jenkins said. Like Mr. McCraney’s mother, she had been sexually abused, and she had gotten pregnant as a teenager, but she still went on to find work as a nurse’s aide and raise her older children before succumbing to addiction. “She beat all these things, and she couldn’t beat this. And I think she had held on for so long and eventually you break, and I think crack cocaine filled that break.

“I don’t judge her. And the beauty in that is that when I create these characters when I’m on set, I’m not judging them either.”

Image

Barry JenkinsCreditScott McIntyre for The New York Times

This is demonstrated most radically in the character of Juan, played brilliantly by Mahershala Ali.

Juan is a drug dealer who sells to Chiron’s mother. But he is also the young Chiron’s father figure and mentor. He invites the child into his home and life, providing refuge from the family chaos. In a breathtakingly beautiful scene, Juan takes Chiron out into the ocean and teaches him how to swim. I remember thinking, as I watched it, that this scene probably appeared fantastical, revisionist, to many viewers.

But Juan is modeled after Blue, the father of Mr. McCraney’s younger brother. As a child, Mr. McCraney looked up to him. Blue was Mr. McCraney’s defender, the person who made sure he had nice clothes, kept the boy’s mother from spanking him and taught him to make salmon croquettes. But when Mr. McCraney was about 6, Blue was shot and killed, and shortly after, the devastated child witnessed his grieving mother overdose on drugs.

Mr. Jenkins himself knew many men like Blue, who are ubiquitous in poor, black communities. They are unusual only in that their representation is so seldom fully rendered in film.

“I do know the dope boy on the corner sometimes goes out and gets bread for the family that doesn’t have it, and equally there are boys on the corner who aren’t selling dope who do terrible things to the community, too,” Mr. McCraney said. “Those stories are all true, and we have to embrace them. If we don’t tell those stories, we lose who we are.”

Before making their movie, the men had a hard time explaining their lives, and the lives of the people they loved. Mr. McCraney recalls an assignment in college where students were asked to write a monologue about their happiest childhood experience.

“I was like: ‘O.K., great. Everybody is going to come in with the time Dad took them pony riding,’” he said, mock rolling his eyes.

If he wrote honestly about his life, he knew that “everybody is going to be like, ‘Oh God, Tarell again.’”

Still some of his happiest moments were with Blue. “So, I wrote about the time a drug dealer got off his crate and taught me how to ride a bike.”

“And I just remember the kind of shock and awe on people’s faces,” he said. “It hurt me. It embarrassed me, and I wasn’t embarrassed because of him or the situation. I was embarrassed because it felt like again me putting on exhibition for mostly white privileged people a world they had never seen.”

But now, by telling their story in “Moonlight,” both the playwright and the director implicitly challenge us to ask: What could men like Blue be, if they were born into different circumstances?

Image

Mr. McCraneyCreditScott McIntyre for The New York Times

Making Their Way Out

Both Mr. Jenkins and Mr. McCraney cannot avoid contemplating how they got where they are. Why did they get out, when so many did not?

It is an impossible calculation.

They would be exceptional no matter where they grew up. How many people in any community are named MacArthur geniuses or make films that get Oscar whispers? Yes, their success is owed to hard work, intelligence, sheer will. But there are a lot of smart, hard-working people in places like Liberty City. That is seldom enough.

So much depends on luck and timing. On not making the irreversible mistake. On meeting the right person at the right time who pushes in the right direction.

For Mr. Jenkins, one person who pushed was Pamela Gilzow Rodriguez — at the time a young, blond third-grade teacher who sped through Liberty City each day in a beige Corvette. She recognized his talent as a writer and was the first teacher to give him an A. (She keeps a file, still, of his essays from third grade and the letters he continued to write her as an adult.) There was also luck: He saw a poster for a filmmaking class as a student at Florida State University, and he thought that might be fun.

For Mr. McCraney, a turning point came when a high school counselor, worried about the bullied young man who didn’t seem to fit in anywhere, referred him to Teo Castellanos, a renowned playwright who ran a theater program for marginalized communities. He would become Mr. McCraney’s “father in art,” nurturing his talent and making sure he had pocket change. And then, in what Mr. McCraney considers a fluke, as a first-year graduate student he was tapped as an assistant to August Wilson, the acclaimed playwright, months before Mr. Wilson died.

Neither artist, though, is comfortable being labeled an exception. That is why the end of “Moonlight” is the part that veers the most from their lives. In the movie’s last act, Chiron goes to prison and ends up becoming a drug dealer himself. Yet, he is still a reflection of them — of Mr. McCraney’s struggle to be seen, of Mr. Jenkins’s struggle to feel worthy of being loved. But more, Chiron is the man, who, given their circumstances, Mr. McCraney and Mr. Jenkins should have become.

Of Mothers and Sons

The movie, at its heart, Mr. Jenkins said, is about how the relationship between a mother and son is fractured, and almost ruined, because of the crack epidemic, and the scenes between Chiron and his mother are excruciating for the men to watch.

For Mr. McCraney, particularly, it is the mother and son reconciliation at the end. “We had conversations similar to that,” he said, “but there was never a moment where she could see how broken I was.”

Yet, Mr. McCraney thinks his mom, were she alive, would have loved the movie. Mr. Jenkins’s mother, who went to rehab years ago and is in recovery, hasn’t yet been able to bring herself to see it. She and her son have discussed the film, but they’ve never talked fully about how his experiences as a child affect him still. He doesn’t want his mother to relive the pain and shame.

That’s perhaps to be expected. So much of “Moonlight” focuses on Chiron’s silence, his inability to speak about the things he is experiencing and feeling. And silence, for both Mr. Jenkins and Mr. McCraney, was the armor of their childhoods. Silence is how they protected their mothers. Silence is how they protect themselves still.

But “Moonlight” has broken that silence. For Mr. McCraney, it is all the things he can never say to his mom. For Mr. Jenkins, it is all the things he won’t say.

Correction:

An article last Sunday about the playwright Tarell Alvin McCraney and the director Barry Jenkins, the creators of the film “Moonlight,” misstated the age Mr. McCraney was when his screenplay of “Moonlight” was sent to Mr. Jenkins. It arrived on Mr. McCraney’s 31st birthday, not his 34th.