In a scene on “Brooklyn Nine-Nine” last season, detective Jake Peralta (Andy Samberg) asks a witness if she recognizes any men in a police lineup. The witness says no, because she was hiding when the crime took place. But, she adds, “I heard him, he was singing along to the music at the bar . . . I think it was that song, ‘I Want It That Way.'”

“Backstreet Boys, I’m familiar,” Jake says gravely, and turns to the lineup. “Number one, could you please sing the opening to ‘I Want It That Way’”?

The very confused suspect starts singing and the others join in, one by one. Jake is so delighted with the singalong (he even contributes with “Tell me why-eee!”) that he’s completely distracted when the witness hears the fifth man sing and pipes up: “It was number five. Number five killed my brother.” Jake jumps. “Oh my God, I forgot about that part!”

The scene is hilarious, but also very believable. Whatever situation you’re in, it’s likely that the person standing next to you will know some — if not all — of the lyrics to “I Want It That Way,” the iconic Backstreet Boys smash that celebrates its 20th anniversary this week. Just test it! Walk up to someone and say, “You are . . . my fire.” They might look at you like you’re crazy, but they will almost certainly know the next line: “The one . . . desire."

Even after two decades, the hit continues to endure, with countless cover versions, karaoke nights and the recent Doritos Super Bowl commercial starring Chance the Rapper. Last month at the iHeartMusic Awards, BSB sang a new track — and then, of course, followed it up with “I Want It That Way,” which sent the crowd into a frenzy. What is it about this song?

“The fact that it continues to capture people 20 years after it was written, in a way that none of my other songs have done, is just astonishing,” said songwriter Andreas Carlsson, who has also co-written hits for ‘N Sync (“Bye Bye Bye,” “It’s Gonna Be Me”), Celine Dion (“That’s the Way It Is,” “I’m Alive”), Katy Perry (“Waking Up in Vegas”) and many more. He acknowledged there’s just something different about how “I Want It That Way” strikes a nerve with listeners.

“The magic behind any song that stands the test of time is not that it’s just clever . . . it actually moves emotions and it makes you feel something,” Carlsson said. For “I Want It That Way,” he pinpoints the classic opening guitar riff, the “mellow but a little bit haunting” verses and the positive chorus “that opens up like the sun is coming out.”

“It just has a special feeling to it,” he added.

Carlsson vividly remembers the morning in 1998 that Swedish pop phenom Max Martin walked into his apartment with an idea for a track called “I Want It That Way”; the two songwriters coincidentally lived in the same building in Stockholm and would occasionally collaborate. Martin, whose launch to fame included writing Britney Spears’s earliest hits, played Carlsson a simple demo with the chorus and a few lyrics, including “You are my fire / the one desire.” (“Like poetry, Swedish style,” Carlsson said.)

Like most simple songs, it became extremely difficult to write. They struggled to figure out a second verse, but then figured why not just repeat the first one? So that’s how it became “Am I . . . your fire? The one . . . desire?” And they eventually finalized the chorus: “Ain’t nothing but a heartache / Tell me why / Ain’t nothing but a mistake / Tell me why / I never want to hear you sayyyyy / I want it thaaaat way.”

Carlsson will be the first to tell you that there’s not a deeper meaning behind the words. It just sounded great and they thought it would be perfect to give to the Backstreet Boys, who were collecting songs for a new album. The members of BSB were thrilled with the track, but the record label executives had one note.

“They wondered if we could rewrite the lyrics,” Carlsson said. “Because they didn’t mean anything.”

So they brought in superstar producer Mutt Lange (Def Leppard, Shania Twain) to help make the lyrics more cohesive, and the Backstreet Boys dutifully rerecorded it. However, the band eventually balked; they liked the first version better. The words might have been weird, but they worked. So the label caved and they reverted to the initial lyrics.

“It actually did make more sense, but it just didn’t have that original feeling,” BSB member AJ McLean told Billboard while promoting a new Backstreet Boys exhibit at the Los Angeles Grammy Museum.

It was the right choice, especially with some stellar co-production by Kristian Lundin. “I Want It That Way” blew up when it was released on April 12, 1999, as the first single from BSB’s third studio album, “Millennium.” It helped propel album sales of 1.1 million in its first week, which broke a record at the time. (“Millennium” went on to sell about 13 million copies.) Even though BSB was often mocked, critics actually seemed to like the song. USA Today deemed it “a zesty platter of creamy R&B lite.”

“ 'I Want It That Way’ is arguably the best pop single to come out of the millennial boy-band culture,” the AV Club wrote in 2013. “It’s not too hard to get even the most pop-averse curmudgeon to acknowledge at least begrudging respect for ‘I Want It That Way.’ It’s a midtempo delight stacked with signature Max Martin theatrics — That bridge! That key change! — and delivered by the five Boys with a panache that supersedes the borderline-nonsensical lyrics. It’s probably still too early to deem ‘I Want It That Way’ a timeless pop classic, but it certainly has a legitimate claim to the title.”

It was nominated for song and record of the year at the 2000 Grammys, though it lost to Santana and Rob Thomas’s “Smooth” in both categories.

“As someone who has written music for 25 years now, you’re just lucky if you put your finger on that emotion that you know millions of people are going to feel,” said Carlsson, who is now the chief strategy officer for Vezt, an app that lets fans buy rights to songs. “Because you can’t really figure that out. It’s there when it wants to be there, and I think we managed to capture it.”

Indeed, the magic continues. “Brooklyn Nine-Nine” co-creator Dan Goor said “I Want It That Way” was the first song the show’s writers pitched for the aforementioned scene. When he asked if there was another option that could work in case they couldn’t procure the rights, they said no.

“We spent an hour trying to come up with a backup,” Goor said. “Nothing seemed right except that song.”

Even though the show’s producers hesitated because of the budget (it’s more expensive to have actors sing a song on TV rather than just play the recording), when the actors performed the scene at the table read, he said “it was one of the most explosive laughs we’ve ever had."

So it stayed. Despite the cost, there are no regrets, Goor said. “We’re very honored to be a small part of a clearly culturally significant song."

Read more:

Let’s talk about how ‘My Heart Will Go On’ is iconic. (Even if you hate it.)

‘N Sync Walk of Fame ceremony: A group hug, emotional speeches and jokes about Joey Fatone

Nashville songwriters are like family. Here’s what happens when things get complicated.