Hamlin will begin the sixth of the 10 races in the Sprint Cup Chase for the Championship in second place behind four-time defending series titleholder Jimmie Johnson.
The pole-sitter traveled around the half-mile oval in 97.018 miles per hour. It was his second pole of the season and the ninth of his Sprint Cup career.
"We decided today we were going to just focus on qualifying, knowing that the No. 1 pit stall is very critical here at Martinsville," Hamlin said. "I love it when a plan comes together."
Hamlin is 41 points behind Johnson, who qualified 19th.
Marcos Ambrose will start on the outside of the first row, having qualified just 0.003 of a second behind Hamlin. Greg Biffle, Ryan Newman and Juan Pablo Montoya rounded out the first five.
Kevin Harvick, who is third in points 77 behind Johnson, qualified the worst among the 12-driver chase field. He will start 36th.