I'm not trying to be ignorant when I say this, because I don't watch F1 or any other types of racing. However, isn't it basically based on who has the fastest car?
That's the most linear way of looking at it. There is a reason they have so many rules that all teams have to abide by. And why there are 3 practices prior to the actual race. It's based on driving ability, direct line speed, down force, when you pit, how often you pit, tire choice, how long you keep on the same set of tires, fuel load, use of DRS and Kers, and how the car was set up before and during the practices.
The difference between Red Bull Racing and say, Lotus, whilst great in F1 terms, is only about 2-3 seconds a lap most of the time for qualifying. The difference between Mclaren and RBR (depending on who's set the car up the best for the track) is around 0.01 - 0.8 seconds.
It's extremely intricate, and complicated. They all have to have a car that weighs the same, uses the same exhaust system, engine power is limited to a certain amount of BHP. The reason one car is faster than another, is due to the team and the driver getting the car to that point.