Earnhardt won his second race in as many starts for Hendrick Motorsports, which he joined this year after leaving the team founded by his late father. Hamlin's victory was the first for a Toyota since that manufacturer joined NASCAR's top series last season.
Earnhardt, who captured the Bud Shootout exhibition race last weekend, will start third in Sunday's 50th running of the Daytona 500. Hamlin will be in the fourth starting position.
The rest of the field was determined by Thursday's two 46-lap races at the Daytona International Speedway.