Yeah, spot on Marcus.
The way qualifying for the 500 works (or at least 'worked', I'm not sure how the new top-35 ruling effected this) is they firstly run the usual one-run, two-lap qualifying session and this sets the front row of the grid (fastest and second fastest qualifier) and the starting order for the Gatorade races (odd-numbered qualifiers in one race, evens in the other, starting in the order they finished qualifying). The finishing order of the two races sets the next 9 or 10 rows of the grid, and the rest of the field is made up out of the remaining cars based on the qualifying speeds and provisionals. There's probably a better explanation at somewhere like nascar.com or jayski.com, but that's basically how it works.
The one thing I've always found interesting is that the front-row qualifiers have to do the qualifying races. They have to race the car they qualify and if they destroy it and have to switch to the backup for the 500, they still have to move to the back of the grid. I think this happened to Ken Schrader in 1990.