Sometimes, you'll see a coach throw a red flag onto the field. This means that he wants to challenge the ruling on the field (because he doesn't agree with what the ref called).
When a ruling gets challenged, the referee watches the play using instant replay (to see if the right call was made or if they messed up).
After reviewing the play, the call will either get overturned (which is what the coach wanted) or it will stand as called. To overturn a ruling, there has to be "indisputable visual evidence" - which means it has to clearly show on the replays. The officials get the same replays that the TV channel broadcasts - so if YOU can't see it clearly, the official can't either. Sometimes, you'll wish there was a better angle - but it is still determined by what is actually SHOWN on the replay.
Each coach gets 2 challenges per game.
If the coach WINS the challenge (and gets the ruling overturned), he is not charged a timeout. If he wins two challenges in the game, then he earns a 3rd red flag for later (if he needs it).
If the coach loses the challenge (and the ruling stands as called), then the team loses a timeout (because - let's face it, the game stopped). So, a team has to have a timeout left in order to use their challenge.
During the last 2 minutes of each half, coaches cannot challenge a play. During that time, plays can still be reviewed, but it has to be a "booth review" - which means the officials in the viewing booth want the field officials to look at the replay.
Not all plays are reviewable though, so if the coach challenges an un-reviewable play, then the ref tells him he can't challenge and the game goes on (and the coach is not charged a challenge or a timeout).