In this paper, an optimal deadlock prevention policy for flexible manufacturing systems (FMSs) is proposed. In an FMS, deadlocks can arise because of a limited number of shared resources, i.e. machines, robots, buffers, fixtures etc. Deadlock is a highly undesirable situation, where each of a set of two or more jobs keeps waiting indefinitely for the other jobs in the set to release resources. The proposed optimal deadlock prevention policy is based on the use of reachability graph analysis of a Petri net model (PNM) of a given FMS and the synthesis of a set of not, net elements, namely places with initial marking and related arcs, to be added to the PNM, using the theory of regions, which is a formal synthesis technique to derive Petri nets from automaton-based models. The policy proposed is optimal in the sense that it allows the maximal use of resources in the system according to the production requirements. Two examples are provided for illustration.