Kendrick Lamar’s “Alright” is considered one of the greatest records in his discography.

But the Pharrell-produced anthem almost didn’t make To Pimp a Butterfly. Speaking with Spotify’s “The Big Hit Show” podcast, producer Sounwave reveals how the iconic song ended up being a last-minute addition to Kendrick’s third studio album.

During one of their meetings, Pharrell was playing Kendrick beats when a Sony Music executive took Sounwave aside to play him an instrumental that Pharrell originally made for another artist, who ended up passing on it.

“I just remember my guy, Sam Taylor said, ‘Hey come check this one out.’ He takes me to another room,” recalled Sounwave. “And he plays me the skeleton of ‘Alright.'”

Sounwave shared his reaction upon hearing the beat for the first time. “And I just remember my jaw drop. It was just like literally just the 808s and the keys, and Pharrell had the melody of ‘We going be alright.’ And I was like, ‘Bro what is this?’ Oh my goodness, I’m freaking out. And I immediately run, I was like, ‘Dot, you have to come hear this.'”

Kendrick was immediately taken by what he heard. “He plays it for Dot, Dot stopped everything he was doing and starts to write to ‘Alright.'”

While they loved the song, they couldn’t get it to fit sonically with the rest of the album. “It was super amazing, super fitting, sonically it was not, like no matter what we did, it just could not fit with the rest of the album,” Sounwave explained. “But we loved that record so much that I said, ‘Okay, I’m not letting this record die.'”

Thanks to some last-minute tweaks, the song ended up on the final tracklist. “I literally have to go back in, last second of the album, like literally at the crunch time, I think we had one more day, and added drums to it.”

Terrace Martin also added some finishing touches. “He gave us a lot more sax part. So we just had to pick and choose. But it was literally freaking out like this record has to make it. And I just remember about three hours, just me and Terrace locked in that room. We came out, I said I think we got something.”

They knew they had one when they played it for Kendrick. “We played it for Kendrick. And I just remember him, his eyes lit up. It was like, we did it. This is finally it.”

“Alright” ended up becoming a standout from To Pimp a Butterfly and Kendrick even performed it at the Super Bowl LVI Halftime Show last month.