The 29-year-old had been a contender for victory for the past few weeks, leading laps both at Fontana and Charlotte, where an incident on a restart and an engine issue respectively hampered his chances of posing a serious threat to Johnson in the standings.
Although Hamlin concedes that his chances of being champion this year are all but gone, as he trails leader Johnson by 352 points, he remains upbeat after taking his third win of the year - the most he has ever scored during a season - as he looks on to a better 2010.
"To me it sucks to not have an opportunity to win the championship this year," said Hamlin. "But hopefully we're setting ourselves up to be one of the favourites hopefully next year.
"It's kind of a fun power position to be racing around guys that are racing for a championship, and you have nothing to lose and all you're doing is going for a race win. That part of it is kind of fun because you can push a little harder and maybe take a few more risks.
"Even though our big goal is not obtainable, we're at least achieving small victories, and that's performing better than what we ever have in the past and getting more wins this year than what we have in years past."
Hamlin's victory at Martinsville took shape during the races's longest green-flag run, which allowed him to catch Johnson and grab the lead from him. Before that he had gambled on a two-tyre stop that gave him track position, and some quick pitstops from his crew after that were also instrumental in allowing him to make the most of his pace.
"Yeah, the guys did a good job," said Hamlin. "We were bouncing back seventh to 12th early in the race from not qualifying well, and every time we'd come in [to the pits], we would give up a couple of spots.
"We needed to get track position, so we got two tyres, which kind of put us in a strange window there, but the guys did a good job on pitroad, and we got a couple of quick cautions, which was a big wrenching because guys at the back were getting tyres.
"So we needed a little bit longer run there, and we got it. The runs just fell our way today. The cautions fell our way even at the end of the race. We were better on older tyres, and it kind of worked to our advantage today."
Hamlin's victory prevented reigning champion Johnson from taking a hat-trick of wins at Martinsville Speedway.
Llorente pens new contractHamlin: Johnson not that much better