NEW YORK —Macklemore & Ryan Lewis were the top winners at the MTV Video Music Awards Sunday night, taking home best hip-hop video for “Can’t Hold Us” and best video with a social message for “Same Love,” a marriage-equality anthem.

Justin Timberlake — the night’s top nominee with

Macklemore & Lewis — topped a memorable night by winning the video of the year trophy for “Mirrors” after he reunited briefly with ’N Sync and received the Michael Jackson Vanguard Video Award on Sunday as the awards debuted in Brooklyn.

Timberlake
wrestled the spotlight away from a rehabilitated Lady Gaga, an X-rated Miley Cyrus and a vengeful Taylor Swift.

Other winners included Bruno Mars, Pink and Nate Ruess for best collaboration, Thirty Seconds to Mars for best rock video and Selena Gomez for best pop video. One Direction won song of the summer.

Timberlake, dressed in a black suit and black hat with a red feather, powered through a breathless series of solo hits before the other four members of ’N Sync — JC Chasez, Chris Kirkpatrick, Joey Fatone and Lance Bass — joined him onstage, opening with “Bye Bye Bye.”

Up till then, the ladies of pop music dominated as Cyrus became the rare artist to upstage Lady Gaga. But Swift managed to take the spotlight from both after appearing to utter an expletive when One Direction and rumored former love interest Harry Styles appeared at Sunday night’s award show.

Gaga changed costumes four times during her first return to the stage since hip surgery as she performed her new single “Applause” at the top of the show, opening in a white nun’s habit and square headdress, and ending up surrounded by unitard-clad male dancers and wearing a thong bikini decorated in shells.

Cyrus appeared onstage with a multitude of dancing teddy bears in a bodysuit adorned with a cartoon character to her song “We Can’t Stop,” changed into a nude bikini, and when Robin Thicke appeared on stage to perform “Blurred Lines,” she gave the singer a lap dance.

Kanye West continued his stark portrayal of new music from his album “Yeezus,” performing “Blood on the Leaves” with its controversial Nina Simone “Strange Fruit” sample in silhouette in front of a black and white picture of a tree.