In this paper, we investigate the problem of optimal reliable relay selection in multiuser cooperative wireless networks in the presence of malicious relay nodes. A general discrete time queueing model for such networks is introduced which takes into account the dynamic variations of the channel state, the dynamic malicious behaviour of relay nodes as well as stochastic arrival of data packets into the system. The model consists of a set of mobile users, one destination node and a set of relay nodes which may be either mobile or fixed. The system uses the benefit of cooperative diversity by relaying in the decode and forward mode. We assume that each user either transmits its packets directly to the destination (direct mode) or transmits them with the cooperation of a selected relay node (cooperative mode). It is assumed that a centralized network controller manages the relay selection process in the system. At each time slot, a malicious relay node in the system may behave spitefully and refuse to cooperate with a user deliberately when it is selected to cooperate with that user. A malicious relay node usually acts stochastically to hide its malicious behaviour for longer time. In such a system, at each time slot the network controller should decide whether a user has to cooperate with any relay node or not and if so, which relay node must be selected for cooperation. First, we show that the malicious behaviour of relay nodes makes the stable throughput region shrink. Then, we propose a throughput optimal secure relay selection policy that can stabilize the system for all the arrival rate vectors strictly inside the network stability region. We show that the optimal policy is equivalent to finding the maximum weighted matching in a weighted bipartite graph at each time slot. Finally, we use simulations to compare the performance of the proposed policy with that of four other sub-optimal policies in terms of average queue occupancy (or queueing delay).