A yellow flag means that there is a hazard on the race track and that the drivers should slow down and stay behind the pace car. This flag typically is displayed when there has been an accident. However it can come out for other reasons such as, light rain, debris, an emergency vehicle needing to cross the track, a NASCAR tire check, or even if an animal has wandered out onto the track.
During a yellow flag situation it is absolutely forbidden to pass the pace car unless specifically told to by NASCAR (such as the "Lucky Dog"). Doing so will result in a penalty.
At most tracks, except road races, the yellow flag period will last a minimum of three laps. This to allow adequate time for all drivers to pit and catch back up to the pace car for the restart.