By MICHAEL M. GRYNBAUM

When a witty young woman named Tracey Wigfield joined the writing staff of “The Mindy Project” in early 2013, Adam Countee was dumbstruck.

“I don’t want anything to appear treacly in print, but I honestly fell in love with her the day I met her,” he said. That night, he texted his brother: “This woman is going to be your sister-in-law.”

So he was disappointed to learn that Ms. Wigfield — a TV comedy prodigy who was about to win an Emmy Award for writing, with Tina Fey, the series finale of “30 Rock” — was already married, with a small child. It took several days before he, along with the rest of the writers, discovered that was not actually true.

“Tracey was like, ‘What the hell are you talking about?’” said Matt Warburton, a former “Simpsons” writer who oversees the “Mindy” writing staff. “You could see young Adam’s eyes light up.”

The mix-up stemmed from a joke Facebook photo involving a fake belly, which had confused even Ms. Wigfield’s old teachers from Catholic school. (“They were like, ‘Congratulations on the birth of your child,’” she said.)

Mr. Countee and Ms. Wigfield soon discovered they had both grown up in close-knit families in New Jersey (she in Wayne, he in Watchung), making home movies with siblings and dreaming about careers in show business.

“They talked for 20 minutes about what malls they went to growing up,” said Mindy Kaling, the creator and star of “The Mindy Project.” “In a way that I can only describe as shocking, and kind of unconscionable, how boring it was.”

For Mr. Countee, it was riveting. “I’d never heard my brother talk about anyone or anything like that in his entire life,” his brother Brendan said.

Ms. Wigfield, 32, came early to TV, appearing in an ad for a toy called the Glitterator when she was a child. (In a YouTube clip that she said “has haunted me always,” Ms. Wigfield is seen shouting the slogan: “It’s Glitter-ific!”)

After college, she worked as a page at the “Late Show” on CBS, directing audience members to the bathrooms. David Letterman’s executive producer, Rob Burnett, recommended her to Ms. Fey for an assistant’s job on “30 Rock,” where she rose to become a writer and producer, creating characters like D’Fwan, an aspiring matchmaker for wealthy dogs.

“Weirdly, now she won’t return my phone calls,” Mr. Burnett quipped.

Ms. Wigfield moved to Los Angeles for Ms. Kaling’s show, and she was homesick. Mr. Countee, who has an infectious smile and James Brown-caliber dance moves, “felt like home,” she said. “We’d be sent off on writing tasks together and would just laugh until you cry.”

But while Ms. Wigfield did not have a baby or a husband, she did have a boyfriend back in New York, whom she had dated since college. Mr. Countee’s entreaties fell flat.

“He kept inviting me to go to a farmers’ market with him,” she said. “I’m thinking: ‘Do people in L.A. just do that? Walk around and get their vegetables together?’ It wasn’t really on my radar.”

For Mr. Countee, 35, who had been rejected from NBC’s page program three times, finding gigs in Hollywood had meant no time for a serious relationship. “I was getting comfortable with the idea that maybe I could be the cool uncle for the rest of my life,” he said. “Bring a different chick home to Thanksgiving every year.”

But his co-worker stood out. “I probably laughed a little too loud at all her jokes, and was a little too stung when she didn’t laugh loud enough at mine,” he said.

(Told this, Ms. Wigfield laughed. “He likes to paint this picture: ‘I never loved another woman until I met you,’” she said. “He did fine! Every woman I’ve ever met who works in the entertainment industry has been on a date with him.”)

When “Mindy” wrapped in spring 2013, Ms. Wigfield was headed back to New York, unsure if she would return to Los Angeles. Sensing his final chance, Mr. Countee asked Ms. Wigfield to what she thought was a casual dinner.

Afterward, he confessed his feelings in a clumsy soliloquy — at one point, he dropped his ChapStick on the sidewalk and chased after it — that was delivered through the passenger-side window of her car. “I think I’m crazy about you,” he said.

Ms. Wigfield listened in what she described as a state of mounting horror.

“I was like, ‘Oh, God, this cannot be,’” she said. “‘I’ve got to shut this down.’” Mr. Countee wincingly recalled her exact response: “Oh. O.K.”

He went home, she flew east. They did not speak for three months. “I would have been more angry at myself for not saying anything,” he remembered thinking.

Interactive Feature | NYT Living Newsletter Get lifestyle news from the Style, Travel and Food sections, from the latest trends to news you can use.

Ms. Wigfield’s relationship soon ended. But when she decided to return to Los Angeles that summer, she and Mr. Countee, their last conversation still lingering, kept their distance.

“I just needed some space,” she said. “I had been in a long relationship. I very much wanted to be single, just single for a while.” And Mr. Countee’s earnestness left her feeling “very scared to reconnect.”

“He was so sure about it, almost in a way that made me kind of nervous,” she said. “Why do you know this? That we’re the one for each other? Is this guy crazy? Why is he this confident?”

When Ms. Wigfield and her sister, Ashley, moved into a new Los Angeles apartment around Labor Day, she invited Mr. Countee to a housewarming. He texted: “Do you feel like our friendship hiatus can be called off?”

They resumed being friends, though she continued to see other people. Still, she said, on those dates, “in the back of my mind, I was like, ‘Nobody’s as fun as him.’”

Mr. Countee, meanwhile, was working an inside source: Ashley. At a Thanksgiving dinner at the home of the actor Ike Barinholtz, she advised him to be patient but persistent. “This was the first time I had really been invested in trying to build a serious relationship,” he said. “I didn’t want to flail on the gas too hard.”

Encouraged, he sent Tracey an e-vite for a formal date, which she found charming. “O.K., you’re being stupid,” she said to herself. “You should go out with him. This is a fool’s errand to try to find something else.”

They began spending more time together, and Mr. Countee visited the Wigfield homestead in New Jersey over Christmas. Ms. Wigfield’s best friend, Lang Fisher, sensed a change. “I know you’re in love with this guy, and you should be with him,” she told her.

Finally, Mr. Countee heard what he had been waiting for. “Tracey was hilariously perfunctory about it,” he said. “‘So do you want to just date only each other or what?’ I was like, ‘Yeah, let’s do that.’”

“I just started feeling like I don’t ever want to not be with him,” she said. “I am sort of brash and confident and loud and quick to judgment, and he softens my edges a little bit. He does so much to make me a kinder, better person.”

Their professional collaboration had helped, too. “Being in a writers’ room is essentially just sitting around a table with 10 other people telling personal stories and eating all your meals together,” Ms. Wigfield said. By the time they started dating, she already knew that he secretly traced Disney characters into his teenage years.

In March 2015, Mr. Countee invited her to a Santa Monica hotel suite, which he had decorated with rose petals and votive candles. “She was three and a half hours late,” he said. “I was sitting in the dark while the candles burned down to the wicks.”

Unaware of his plot, she had decided to try a far-flung Mexican restaurant. When she finally arrived, he proposed. Their siblings were waiting downstairs. “He knew I’d want my sister to be there,” she said.

On May 21, beneath the soaring apse of the Church of St. Paul the Apostle in Manhattan, they were married in a formal Roman Catholic ceremony before 244 guests. Ms. Wigfield’s childhood pastor, the Rev. Kevin Downey, led the service.

The bride wore a cascading white Anna Maier dress, with a chapel-length veil that stretched nearly seven feet. The groom wore a black Ralph Lauren tuxedo with patent-leather shoes. Neither could stop smiling.

Afterward, Ms. Wigfield switched her formal shoes for a pair of red Chuck Taylor sneakers. Guests made their way across town to Cipriani 42nd Street, where they found cherry blossom centerpieces and a rollicking rhythm-and-blues band.

Mr. Countee moonwalked into the reception hall and immediately began to break-dance. He had swapped his tuxedo jacket for a sparkling gold blazer, a wedding gift from the bride (no Glitterator, though).

By midnight, Ms. Fey had danced on a chair, cheering along to a gospel number, and the groom was declaring the celebration “the best night of my life.”

It had been a big night and a big week for the bride, too: Days earlier, her new pilot, “Great News,” was picked up by NBC. The series, for which Ms. Fey is an executive producer, is about a TV newswoman whose mother takes an internship at her station.

Mr. Countee, who writes for “Silicon Valley” and is developing a project for HBO, helped with the pilot. “It’s such a blessing to have a smart, funny writer living in your house,” he said. “The flip side is when you’ve had a long day at work and just want to hide in the dark and watch an episode of ‘Fargo’ and your partner keeps yelling from the other room, ‘Is there a funny thing where a character falls in a toilet?’”

Ms. Kaling, in her toast at the rehearsal dinner, took credit for bringing the couple to the same writers’ table.

“Though it would have been nice,” Ms. Kaling said, smiling, “if people were actually focusing on working and making the show better, instead of falling in love with each other.”