We propose and evaluate an energy-efficient scheduling algorithm for detection of mobile targets in wireless sensor networks. We consider a setting where the sensors are deployed for both road surveillance and mobile target tracking. A typical example would be where some sensors are deployed along the entrance roads of a city to detect the vehicles entering the city and other sensors can wake up and track the vehicles after detection. We show an important relationship between the overall energy consumed by the sensors and the average detection time of a target, both of which are very critical aspects in our problem. To this end, we define the quality of surveillance (QoSv) as the reciprocal value of the average detection time for vehicles. We propose an optimal scheduling algorithm that guarantees the detection of every target with specified QoSv and at the same time minimizes the overall energy consumed by the sensor nodes. By minimizing the energy consumed, we maximize the lifetime of the sensor network. Also, along with the quality of surveillance guarantee, we ensure that no target goes undetected. We theoretically derive the upper bound on the lifetime of the sensor network for a given QoSv guarantee and prove that our method can always achieve this upper bound. Our simulation results validate the claims made on the algorithm optimality and QoSv guarantee.