LOS ANGELES — At the Grammy Awards on Sunday night, pop’s megastars will compete for the music industry’s most prestigious trophy, and put on flashy performances that are sure to ricochet through social media.

But the producers behind the program, which is to be broadcast live by CBS at 8 p.m., are hoping that the biggest show-stopper of the night will be a much more solemn event: an on-air wedding of 34 couples — gay, straight, old, young, of many races and many colors. The ceremony will be part of the hip-hop duo Macklemore & Ryan Lewis’s performance of their Grammy-nominated song “Same Love,” which became a marriage-equality anthem last year just as that issue was drawing intense national attention.

Photo

Mr. Lewis, the group’s producer, said that the weddings “will be in our minds the ultimate statement of equality, that all the couples are entitled to the same exact thing.”

The segment follows what the Grammy organizers said was the show’s long history of addressing timely social issues through music, like Elton John’s duet in 2001 with Eminem, who was then widely criticized as homophobic.

“We’re serious about this,” said Ken Ehrlich, the longtime producer of the Grammys.

Yet as part of a televised awards show that works hard for its ratings, showbiz will also play a part in this sacrament. Queen Latifah will officiate at the nuptials, and Madonna will join the number with Macklemore, Mr. Lewis and the song’s featured vocalist, Mary Lambert. (Queen Latifah was recently deputized by Los Angeles County to perform the weddings and will sign the marriage certificates for each couple.)

Grammy organizers said they knew that controversy might be inevitable, given those who oppose gay marriage or who might see the segment as trivializing a serious matter.

“I expect that people with all kinds of opinions might voice them, and that’s healthy,” Neil Portnow, the president of the National Academy of Recording Arts and Sciences, which presents the Grammys, said when asked about the potential response.

But he and Mr. Ehrlich argued strongly that the wedding segment is no stunt. “We don’t need to stoop to the level of trying to find gimmicks and sensationalistic approaches to what we do,” Mr. Portnow said.

The idea for the weddings originated last fall when Mr. Ehrlich sat down with Macklemore & Ryan Lewis over a fried-chicken lunch to brainstorm ideas for a possible performance. Knowing that their concerts have occasionally featured onstage marriage proposals, Mr. Ehrlich suggested taking it a step further with a full wedding.

The band was into it, so a casting agency was hired to find the couples, who at first were told only that the ceremony would take place on live television. The couples each signed confidentiality agreements — promising not to tell even their families. The involvement of the Grammys was revealed only in the last couple of weeks.

Leaks about big Grammy performances are common; at the industry parties around Los Angeles this weekend, for example, it seemed universal knowledge that Beyoncé and Jay Z were expected to open the show on Sunday night. Yet word of the wedding segment has been kept unusually quiet.

Among those tying the knot on Sunday night is Mr. Lewis’s sister Laura, who was already engaged to her boyfriend, Alex.

“A night that is already tremendous for me, for the music,” Mr. Lewis said, “but to have my sister get married and my family there watching it — that makes it a whole other level of amazing.” The group is nominated for a total of seven Grammys, including song of the year for “Same Love.”

At a wedding rehearsal on Saturday afternoon here at the Staples Center, the couples marched up and down the aisles several times as producers tested lighting and music cues. As the song’s warm piano chords filled the arena and the couples held hands in place, hardened entertainment executives and crew members teared up.

The producer’s planning of the segment showed how delicate the subject of gay marriage can be. Mr. Ehrlich, who learned of Macklemore & Ryan Lewis’s onstage proposals from his daughter, who is gay, said that the segment reflected his own personal beliefs. “But,” he was quick to add, “I would not want to make a broad statement that it represents the views of the academy or the CBS television network.” (CBS representatives had no immediate comment.)

When deciding where to have the couples stand, Mr. Ehrlich thought that having them onstage “could be viewed as more exploitive,” so they were placed in aisles in front of the stage, where they would be close to the audience.

“It seemed like less of a ‘show’ than if I put them onstage,” he said. “I don’t want them to feel as though they’re on parade.”

Even in the last few days before the awards, some aspects of the segment were still being decided, including exactly how long the ceremony would last. Weddings after all, can take awhile.

“It’s not going to take awhile,” Mr. Ehrlich said. “We’re still a television show.”