LOS ANGELES — Sam Smith was the king of the Grammys, taking home three of the top four awards, including song and record of the year for “Stay With Me,” and best new artist, while Beck won album of the year.

“I want to thank the man who this record is about ... Thank you so much for breaking my heart because I have four Grammys,” said Smith, who also won best pop vocal album for “In the Lonely Hour.”

Smith, along with Beyonce, Pharrell and Ed Sheeran, lost album of the year to Beck’s “Morning Phase,” which also won best rock album.

Kanye West, who famously interrupted Taylor Swift when she beat Beyonce at the MTV Video Music Awards, almost walked onstage when Prince announced Beck’s name. Some in the audience seemed shocked, from Pharrell to Questlove.

Beck’s album debuted at No. 3 on the Billboard 200 albums chart and sold about 300,000 units.

Pharrell and Rosanne Cash walked away with three awards each. Pharrell won best pop solo performance for a live version of “Happy,” released in 2013. He also won best music video for the song and best urban contemporary album for “G I R L,” beating Beyonce.

“I am going to moonwalk my way off the stage right now,” said Pharrell, wearing a blazer and shorts.

Pharrell’s performance of “Happy” was dramatic with background dancers in black, musicians in yellow and a choir in white.

When the chorus was supposed to come in, Lang Lang played the piano skillfully. Hans Zimmer also played the guitar.

“Thank you, God,” Pharrell, in a bell-boy hat, said at the end of the performance.

Rihanna gave an impressive vocal performance of “FourFiveSeconds” with Paul McCartney to her right and Kanye West to her left. Her hair was slicked back, and she rocked a black suit like her co-stars

Katy Perry, in all white, sang the ballad “By the Grace of God” after a woman who had been abused talked about getting help and moving on with her life. A video of President Barack Obama appeared before she spoke, and he encouraged artists to help out.

“It’s on us, all of us, to create a culture where violence isn’t tolerated,” he said.

Another serious moment came with Prince, who earned a standing ovation when he walked onstage to introduce album of the year.

“Albums — you remember those? They still matter. Like books and black lives, they still matter.”

Madonna, dressed as a matador, performed “Living for Love” atop a platform surrounded by a plethora of background dancers wearing bull masks. A choir did most of the singing, while Madonna danced and the audience at the Staples Center clapped in unison. She ascended into the air as the performance finished.

West performed on a nearly pitch-black stage, with a light glowing from under his feet (he also sported the new sneakers he designed). He sang the new song about his late mother, “Only One.”

Annie Lennox was a powerhouse when she sang “I Put A Spell On You” and joined Hozier for “Take Me to Church,” nominated for song off the year.

Beyonce won best R&B song and R&B performance for “Drunk In Love” and surround sound album for “Beyonce.”

“This has been such an incredible year,” she said, thanking her “beloved husband” and “my daughter who is watching.”

In one of 23 performances, AC/DC kicked off the show with a performance of their latest single, “Rock or Bust,” and then transitioned into the classic “Highway to Hell.” It earned a rousing applause from Pharrell, Lady Gaga and Katy Perry, who wore devil horns.

Ariana Grande gave a stripped, piano-led performance of “Just a Little Bit of Your Heart,” a song co-written by One Direction’s Harry Styles, while Miranda Lambert brought a rock-heavy vibe to “Little Red Wagon.” She won best country album for “Platinum.”

“I put my heart and soul in this record,” she said. “Thank you so much for this amazing night. I love y’all!”

Cash led the pre-show with three Grammys, while Eminem, Kendrick Lamar, Chick Corea and the “Frozen” soundtrack earned two awards apiece.

“Reagan was president last time I won a Grammy,” said Cash, who won best American roots performance, American roots song and Americana album. “I just showed up for work for 35 years and this is what happened.”

During the pre-show ceremony Sunday afternoon, country star and Breaux Bridge native Hunter Hayes presented the Grammy for best regional roots music album to Lake Charles-based singer-accordion player Jo-El Sonnier for his album, “The Legacy.”

“Thank you so, so, so very much,” the emotional Sonnier said. “First, God is good. I want to thank him for everything he’s given me, through my life and through my career. … May this legacy live on and on, for everybody.”

Two other Cajun music acts from southwest Louisiana, the Magnolia Sisters and Bonsoir, Catin, were nominated in the category in which Sonnier won.

“20 Feet From Stardom,” a documentary about backup singers for the stars, including New Orleans native Merry Clayton, won the Grammy for best music film.

Lamar, who lost in seven categories last year, marked a redemption by winning best rap performance and rap song for “i.” Eminem won best rap album, beating Common and Iggy Azalea. He also won best rap/sung collaboration for “The Monster” with Rihanna.

The late Joan Rivers won best spoken word album for “Diary of a Mad Diva,” and her daughter, Melissa Rivers, was on hand to accept the award.

“If my mother was here tonight, she would not only be honored and thrilled to be holding her first Grammy,” Melissa Rivers said. “She would most likely have it copied and on the air on QVC by 11.”

Advocate staff writer John Wirt contributed.