"It's been a long time coming," said Joe Gibbs, who got his first All-Star victory in 24 races.
Hamlin won the pole for Saturday night's race, was decent through the first four 25-lap segments, but was slotted sixth based on average finish for the mandatory final pit stop.
His No. 11 team, one of the top pit crews in the Sprint Cup Series, got him back on track in first.
"The pit crew just knocked it out of the park," said Hamlin. "That was prime-time right there."
Hamlin was aided when Brad Keselowski, who raced Hamlin off pit road but exited second, was flagged for speeding.
Hamlin controlled the restart and jumped out to a huge lead, and Harvick moved into second and tried to chase down the leader.
But it was never going to be an easy task -- every driver in the 20-car field wanted to be out front for the final 10-lap sprint to the finish because NASCAR's current rules package has shown that the leader, in clean air, is very difficult to pass.
Although Harvick briefly closed the gap, he had to get out of the throttle when his car drifted too far up the track, and he never got close enough to even attempt a move for the lead.
Hamlin collected the $1 million prize while giving manufacturer Toyota its first win in the All-Star race and Gibbs its first win in 24 appearances.
"Everybody wants to be an All-Star," Hamlin said from victory lane. He praised Joe Gibbs, who had won all of NASCAR's crown jewel races but had come up empty in the All-Star race.
"He's got a lot of great accomplishments. He's won every big race on this circuit, so this means a lot," said Hamlin.
Then, in a rush to start the postrace celebration, he tried to hurry along his postrace news conference. He detailed his race and succinctly summarized the victory: "Everything just came together perfectly for those 10 laps. ... That should cover everything."
Harvick finished second and lamented a lost opportunity.
"Thought we were in a good spot," he said. "I had committed to the center of the corner and just really lost the front of the car up the racetrack, had to get out of the throttle, lost five or six spots."
Kurt Busch finished third and believed Hamlin jumped the restart.
"We restarted second and we're going to have to go to the tape and look at it to see if Denny went too soon," Busch said. "I was asleep at the wheel on the restart."
Kyle Busch was sixth in his first race back since he was injured in a February crash at Daytona. Busch missed the first 11 Sprint Cup races of the season after breaking his right leg and left foot when he crashed into a concrete wall in the Xfinity Series opener.
"Real fortunate just to get back in the race car, get out there and feel things out," Kyle Busch said. "Everything felt good and getting to pit road, all that, everything was fine."
After getting penalized for speeding on pit road and later having to pit to fix a loose wheel, Busch worked his way back toward the front but was never in contention during the final 10-lap segment.
Busch never led a lap in his ill-handling car, but the run at Charlotte Motor Speedway was a positive step in his return from a scary accident.
"I'll be sore for a couple days, just muscles that haven't been woken up quite like this in a little while," Busch said. "It's nothing new. Typically, I get that in the beginning of the year anyway and it takes a few weeks to get warmed up.
"Being out of the race car the longest I've ever been in my career, it's a wake-up call."
He returned for the non-points All-Star race as a tuneup for next Sunday's Coca-Cola 600, the longest race of the season.
Busch said he was comfortable in his No. 18 Toyota and it served as a good tuneup for the 600, part of a busy upcoming week that includes the scheduled birth of his son. His wife, Samantha, is set to be induced Monday.
"Looking forward to the days leading up to next week because our first son is coming," Busch said.
Kahne was seventh and followed by Joey Logano and then Keselowski, who said he had to hustle off pit road on the final stop to have any shot at the win.
"Whoever gets the clean air with this format and this rules package is going to drive away," Keselowski said. "I knew when I came out of my pit stall and the 11 was pulling out with me that I either beat him to that line or lose the race.
"I told my crew chief I'd rather go down swinging than take a strike and wonder what might have been. I swung and missed."
The race was free of competition cautions, the first time since 2008 there were no yellow flags for on-track incidents or issues.
The Associated Press contributed to this report.