The announcement that Madonna would be paying tribute to Prince at the Billboard Music Awards caused no shortage of controversy — perhaps understandably. After all, Prince was probably the greatest musical genius of his generation; while Madonna is a phenomenal talent at many things, her chops as a musician are maybe not at the top of that list.

But the tribute is much more fitting than it might seem to some. More than any other music stars, the two defined the ‘80s, and they enjoyed a kind of frenemy relationship that saw them collaborating several times over the years and hanging out even more — the most recent time that we know of was a late-night private concert at Paisley Parkin October that was attended by around 60 people, about half of whom were Madonna and her entourage, when she was in Minnesota on her Rebel Heart tour.

And while just one song has emerged from their brief period of collaboration around the time of Madonna’s Like a Prayer album (“Love Song,” although it’s Prince’s guitar you hear at the start of “Like a Prayer”), it wasn’t for lack of trying: There’s reportedly a Prince-produced version of “Like a Prayer” out there somewhere, and Madonna was originally slated to costar in Prince’s ultimately disastrous 1990 feature film Graffiti Bridge.

Madonna knew enough to go to an expert for some words of praise: Questlove, drummer of the Roots, musical director of The Tonight Show Starring Jimmy Fallon, lifelong Prince fan, expert (he’s taught a course on Prince’s music at New York University) and occasional collaborator. “All of us live in the land of music, and his departure from it was an earthquake,” he said, before making some comical remarks about “every time we hear a scream [he let out a squeak]… every time we see a yellow suit with the rear cut out…”

Prince’s full “Let’s Go Crazy” spoken intro played as the lights came up on a purple throne with its back to the audience — it slowly turned around to reveal Madonna, wearing a flawless suit clearly in homage to the ones Prince wore on the 1984-85 Purple Rain tour, with a cross hanging from her wrist and holding a cane, which Prince did in his last few years, including his performance at the 2013 BBMAs.

The music deftly shifted to “Nothing Compares 2 U,” which Madonna sang in Sinead O’Connor’s arrangement — accompanied by a string quartet, two singers, two keyboardists and a vaguely trap drum machine — playing it safe and nailing most of the notes. Tears were visible in her eyes by the end of the first verse.

She finished the song — and then, in a surprise, Stevie Wonder joined her onstage for a coda of the chorus from “Purple Rain.” Purple spotlights criss-crossed the arena as the crowd waved illuminated purple wristbands in time with the song, with Wonder leading a gospel-inflected a cappella breakdown of the chorus as the cameras panned to audience members, many of them in tears.

Stevie thanked Madonna, Madonna thanked Stevie, and then said, “And most of all, thank you Prince Rogers Nelson, for all that you have given us.” It was a perfect ending to a moving tribute.