Assuming you have been properly stopped by law enforcement based on their reasonable suspicion that criminal activity was afoot, the police may detain you long enough to investigate that reasonable suspicion.  The detention must be temporary and last no longer than is necessary to effectuate the purpose of the stop.