The Ferrari driver remained sedated in a hospital with multiple skull fractures after a crash in his Ferrari during qualifying on Saturday.
Hamilton, Formula One's defending champion, picked up his first victory of the season to snap a streak of 11 races without a top-three finish, dating to his win at China last year.
Massa, whose place on the grid was left vacant, was listed in life-threatening but stable condition on Sunday.
"I've had a great relationship and we've had some great battles and not to see him today was difficult," said Hamilton, who battled the Brazilian to the final corner for the 2008 title. "We miss him and wish him well and wish him a speedy recovery."
Safety also became an issue in Sunday's race when Fernando Alonso's right front wheel came off his Renault and bounced wildly down the track as he rounded turn No. 9.
After the race, Renault was suspended for the upcoming European Grand Prix by governing body FIA, which said the team failed to advise Alonso that a nut on the wheel was not properly secured.
Renault appealed the penalty on Sunday. It has 48 hours to lodge the appeal and eight days to present the grounds of the appeal.
Alonso, who was on the pole, retired and overall leader Jenson Button finished seventh. The Brawn GP driver now leads Webber by 18.5 points.
Hamilton, who finished 11.5 seconds ahead of Raikkonen, started pumping his fists in celebration before even crossing the line, unable to rein in his emotions following a largely frustrating season for the British driver and his team.
He patted the No. 1 sticker on his car emphatically after emerging from the cockpit and then had to wrestle the celebratory champagne back from team principal Martin Whitmarsh as McLaren got to the podium for the first time this season.
"It's an incredible feeling to be back here after what feels such a long time away and such a struggle with me and my team," Hamilton said after picking up his 10th career victory. "We didn't expect to win this season. Undoubtedly we caught up this weekend."
Raikkonen was the lone Ferrari car on the Hungaroring circuit after Massa was struck in the helmet by a loose piece from another car, causing him to crash into the tire barrier at high speed. Ferrari's garage displayed a "Forza Felipe Siamo Con Te" (Be Strong Felipe, We Are With You).
"It was very unfortunate what happened. Yesterday was terrifically freakish," Webber said. "But we don't want to get too carried away with it. We missed him on the grid but the show must go on."
It was Button's worst result this season after winning six of the first seven races, and moved him to 69 points in the overall standings. Webber has 51.5 points, while Vettel's retirement after 29 laps left him on 47 points.
Brawn GP's Rubens Barrichello finished 10th to stay on 44 points as Red Bull also trimmed Brawn GP's lead in the constructors' series to 15.5 points with seven races left.
"We're still up here, we haven't been blown away by any means," Webber said. "We're still a force."
Hamilton was closing in on Alonso before the pole-sitter was forced to retire when his front right tire came off the car and bounced wildly down the track. F1's safety measures are likely to be questioned further with that scene coming a day after Massa's accident and one week since F2 driver John Surtees, son of former F1 champion John Surtees, died in a crash caused by a loose tire.
Hamilton muscled past Raikkonen at the first turn and then eventually got past Webber and pulled away from Raikkonen following Alonso's exit.
"It's a good day for the sport. Lewis is back and McLaren is back," Webber said.
Vettel's retirement came after a poor start and a slight collision with Raikkonen around the first corner, when the young German dropped from second to seventh.
"I was on the inside, had a clean run to accelerate and then his car came sideways and yeah, we touched," Vettel said. "He crashed into my car."
Jaime Alguersuari, who became the youngest driver to start an F1 race at 19 years, 126 days, finished ahead of last-place Toro Rosso teammate Sebastien Buemi in 15th.