A recent post here detailed the conditions for conducting searches as laid out in the Fourth Amendment of the Constitution of the United States of America. However, not all situations culminate in a full search. As Maryland residents may be aware, in some situations people are often detained briefly. The conditions for these brief detentions and stops also stem from the Fourth Amendment.
If a police officer has "reasonable suspicion" that someone is dangerous, about to use a weapon and either engaged in or is about to be engaged in criminal activity, the officer can stop that person for a brief pat down search of their outer clothing. Reasonable suspicion is lesser than probable cause and looser, which is why it is not enough to justify a full seizure, just a brief pat down.
When this "Terry Stop" happens in a traffic setting, the condition is that it must be lawful for the police to detain the vehicle and its occupants while an investigation is being conducted into the violation. In this situation, there is no requirement that the police officer believes that the occupants are involved in any criminal activity.
When questioning the prosecution's case with regards to felonies such as drug crimes that stem from drugs being seized from a vehicle, it may be important to question the reason behind the initial stop. Courts look at the totality of the circumstances to determine if reasonable suspicion existed or not, and an experienced defense attorney may be able to help disprove the allegations of reasonable suspicion.