"I did not see this coming," said "Breaking Bad" creator Vince Gilligan, tipping his hat to competitor "House of Cards," the first online contender for top Emmy honors.
Jeff Daniels won the Emmy for best drama series actor for his portrayal of an idealistic TV anchorman in "The Newsroom," with Claire Danes capturing top actress honors for her troubled CIA agent in "Homeland."
Daniels noted that he'd also received an age 50-plus acting honor from AARP, which represents the interests of older Americans.
"With all due respect to the AARP, this is even better," Daniels said.
Danes, who captured her second trophy for the terrorism drama, paid tribute to one of the series' writers, Henry Bromell, who died last March and who received a writing Emmy posthumously Sunday.
The ceremony often struck a melancholy note with extended tributes to stars and other industry members who died in the past year.
"Well, this may be the saddest Emmys of all time but we could not be happier," said "Modern Family" executive producer Steve Levitan.
It also included upsets, defying the conventional wisdom in several categories, including acting categories.
"This just in. Nobody in America is winning their Emmy office pool. Surprises galore," host Neil Patrick Harris.
Danes' win ended the hopes that "Scandal" best actress nominee Kerry Washington would become the first African-American to win in the category.
Julia Louis-Dreyfus claimed her second consecutive best comedy actress award for her role as an ambitious political second banana in "Veep," with Jim Parsons again claiming the top comedy acting trophy for "The Big Bang Theory."
"This is so much good fortune it's almost too much to bear," said Louis-Dreyfus. "I'm very grateful to have the opportunity to make people laugh. It's a joyful way to make a living."
Parsons added to the awards he won in 2011 and 2010 for the role of a science nerd.
"My heart, oh my heart. I want you to know I'm very aware of how exceedingly fortunate I am," he said.
Merritt Wever of "Nurse Jackie" won the night's first award, for best supporting actress in a comedy series, kicking off the ceremony on a surprising note and with a remarkably brief acceptance speech.
"Thank you so much. Thank you so much. Um, I got to go, bye," Wever told the audience after besting a field that included two-time winner Julie Bowen of "Modern Family."
"Merritt Wever, best speech ever," host Neil Patrick Harris said.
Backstage, she offered an explanation: "I'm sorry I didn't thank anyone. I was going to cry."
Tony Hale of "Veep" claimed the trophy for best supporting actor in a comedy, a category that has been the property in recent years of the men of "Modern Family."
"Oh, man.... This is mindblowing, mindblowing," Hale said.
Laura Linney was named best actress in a miniseries or movie for "The Big C: Hereafter." ''The Voice" won best reality-competition program, and Tina Fey won for writing "30 Rock."
Michael Douglas was honored as best actor for his portrayal of Liberace in "Behind the Candelabra," besting his co-star Matt Damon. The film also captured a top trophy as best movie or miniseries.
"This is a two-hander and Matt, you're only as good as your other hand," Douglas said, then got really racy: "You want the bottom or the top?"
Bobby Cannavale, from "Boardwalk Empire," won as best supporting actor in a drama, and Anna Gunn from "Breaking Bad" won the best actress award in the same category.
Derek Hough of "Dancing with the Stars" won the trophy for best choreography, which offered an opportunity to include an upbeat dance number late in the show.
In the variety show category, "The Colbert Report" broke a 10-year winning streak held by "The Daily Show with Jon Stewart." It also won for best writing for a variety show.
The ceremony's first hour was relatively somber, with memorial tributes and a doleful song by Elton John in honor of the late musical star Liberace, the subject of the nominated biopic "Behind the Candelabra."
"Liberace left us 25 years ago and what a difference those years have made to people like me," said John, who is openly gay in contrast to the closeted Liberace portrayed in the TV movie.
Robin Williams offered another tribute. "Jonathan Winters was my mentor," Williams said of the actor-comedian. "I told him that and he said, 'Please, I prefer 'idol.'"
Also honored was Cory Monteith, the "Glee" star who died at age 31 in July of a drug and alcohol overdose. "His death is a tragic reminder of the rapacious, senseless destruction that is brought on by addiction," said his co-star Jane Lynch.
The inclusion of Monteith as one of five extended goodbyes despite his abbreviated career and the exclusion of such enduring stars as Jack Klugman and Larry Hagman drew criticism from some. Adam Klugman, son of "The Odd Couple" actor, called his father's omission "criminal."
Edie Falco recalled her late "The Sopranos" co-star James Gandolfini, saluting him for his "fierce loyalty" to his friends and family and his work with military veterans.
"You all knew Jim the actor. I was lucky enough to know Jim the man," she said.
Harris started out the ceremony with help - and harassment - from past hosts including Jimmy Kimmel, Lynch and Conan O'Brien. When they started to squabble, nominee Kevin Spacey of the online show "House of Cards" got a close-up.
"It's all going according to my plan. I was promised the hosting job this year and they turned me down," Spacey said, channeling the scheming politician he plays on the digital series.
Diahann Carroll, the first African-American Emmy nominee in 1963 for "Naked City," created one of the night's most heartfelt moments when she took the stage with Washington and noted the importance of diversity in the industry and Emmys.
"Tonight, she better get this award," Carroll said of Washington, who covered her eyes in embarrassment. Danes' victory denied Washington.