Last month, "Señorita" by Shawn Mendes and Camila Cabello debuted on the Billboard Hot 100 at No. 2 -- 18 spots ahead of where their 2015 duet, "I Know What You Did Last Summer," peaked. But it took 15 months and eight songwriters (including Mendes and Cabello) to get there.

In spring 2018, Ali Tamposi and Andrew Watt -- who together have co-written hits for 5 Seconds of Summer, Selena Gomez and Little Mix -- had the initial idea for "Señorita" during a writing session with Charli XCX and Clean Bandit's Jack Patterson. Watt later recruited Benny Blanco and Cashmere Cat, and the song was released this June.

Since its Hot 100 debut, the sultry, Latin-inspired pop track has remained in the chart's top five (it remains at No. 3 on this week's tally). The eight superstar writers were never able to be in the same room at once -- yet in the end, that was part of the magic. "Everyone did their piece, and it [was] all for Shawn and Camila, led by Shawn and Camila," Watt says. "This was a labor of love."

Below, Mendes and Cabello's collaborators detail how the summer smash came together.

Charli XCX: I had been working with Ali and Andrew at his studio a few days a week for around a month. In that time, we wrote a song for my album, "White Mercedes." A few weeks later, we were riffing off a beat Andrew played when [Ali had] the initial idea for "Señorita."

Andrew Watt: I was sitting in my backyard before the session, and four aliens landed in my backyard and sat with me. I had this guitar and I said, "I don't know what to do about the session," and they touched me and put this riff up my ass -- this fingerpicking somewhere between Fleetwood Mac and Jose Feliciano. Then I went into the session and played the riff for Ali and Jack and Charli.

Ali Tamposi: When [Andrew] played the chords we all just started singing melodies that kind of naturally flowed with the progression, and then "Señorita" popped out. We latched on to the emotion of the phrase, "I love it when you call me señorita."

Jack Patterson: We wrote it in the first session I had with Andrew and Ali. Watt arranged pedicures for everyone halfway through. I was jet-lagged out of my mind, and the whole thing was surreal.

Charli: And a vintage t-shirt dealer came mid-writing session. But otherwise, were were super focused.

Tamposi: Everyone gets super amped up when the vintage t-shirt guy comes in. I might've bought a Minor Threat sweater that I love.

Watt: I probably made a plan with him a couple days before that, forgot about it, was in the middle of writing [the] song and the doorbell rang. Same thing with the pedicure lady. She put David Bowie stickers all over my toes while I was tracking guitar for "Señorita."

[After the session] I sent the rough chorus to Shawn and was like, "This would be an amazing duet," and he said, "The only person I could do the song with is Camila." When he said that, I was like, "Oh my God, that would be incredible." He came over and we recorded a version of the song with him on it -- that was [the] bones for a long time. He started communicating with Camila and planning with her, and while he was doing that I went over to Blanco's.

Cashmere -- we call him Kitty -- was in [Benny's] studio at the same time. I played the song for Benny, and Kitty's like, "I really like this." I have played him song after song, and he's been like, "It's cool, but I hate it," every time. So I was like, "Dude, please give us whatever you have for this, [I'm] honored that you wanted to be involved." We built around the guitars, but kept the production so simple, because the vocals are everything in this song.

Cashmere Cat: I went over to the studio one day when Watt and Benny were finishing the song, and they let me sprinkle a tiny bit of truffle salt on it. They did all of the heavy lifting. I Postmated us coffee. That's really all I did.

Watt: He's a modest guy. The song would not be the song without him. Cashmere took it from just being really kind of simple and put some nuances in there -- the ambient stuff that you hear is all Cashmere.

After we did the production, it was a long time deciding when would be the right time to [finish the song] -- Shawn released his amazing [self-titled 2018] album, Camila has been hard at work on her album and doing features and stuff. [Months later] it was sounding like it was going be time for the song, and Camila came to my house with Ali.

Tamposi: Shawn and Camila had a lot to do with the lyrics and melody changes to make it tailor-fit to their story.

Watt: Once [Camila] put her spin on it, I flew to England, with her files to see Shawn because we had changed the key of the song. He went from recording the bulk of the stuff in his dressing room to rocking Manchester Arena. Then we got on his bus and went to Birmingham, where we were going to finish off the song on his day off.

I'd brought my microphone that I recorded Camila on. I plug it in, turn on the power box, and we hear "zzzz" and I was like, "What the fuck just happened?" I forgot to change the conversion of power to 220 and I blew the microphone. Me and Shawn look at each other, and Shawn is hysterically laughing on the floor. I'm supposed to leave the next morning because I have sessions back in LA, and I call my assistant like, "Cancel my flight, I'm going to be here for a minute."

The next day we get another microphone at the Birmingham Arena, and Shawn is so fed up with me at this point. He's like, "Dude, I'm about to do four nights at the O2, I need my voice." Finally, he comes in, and murders it. He does all those amazing ad-libs, like [sings] "She loves it when I call her..." I think that amazing raspy tone probably came because literally was so angry.

[Shawn and Camila] were FaceTiming and writing together, but the first time they were in the studio together was a couple of weeks before it came out. Camila really spent her time making sure she did everything right -- she was constantly tweaking lyrics and cut the song a bunch of times. The song was already being mixed [when she came up with] the line, "You say we're just friends but friends don't know the way they taste." She's like, "This line has to be in there," so Shawn had to come in and re-sing the harmonies to that. It was a great couple of days of us all together.

Blanco: When we were all at Watt's studio, Camila and Shawn were there together, and I was like, "Holy fuck, it's actually going to happen." You could just feel the energy in the room. They are both just so fucking talented.

Watt: They wanted to impress each other and cared what each other [thought of their parts]. They both respect each other so much as songwriters and musicians, it was healthy pressure that made them do their best.

Tamposi: These are hard songs to get across the finish line. It went through so many changes, but it couldn't be more perfect.

A version of this article originally appeared in the Aug. 10 issue of Billboard.