In this article, a mathematical model is proposed for the joint planning of maintenance policies and inventory control in a deteriorating production system. A safety stock is maintained to meet the demand during the conduction of maintenance actions and to avoid shortages. The optimal planning of maintenance and inventory improves the productivity of the manufacturing system. In a deteriorating production system, the process has two operational states including in-control and out-of-control states as well as a non-operational state, or failure mode. The time for the transition among the states follows a general continuous distribution. The time duration of maintenance actions is also considered as a random variable. The purpose of this study is to optimize the safety stock level and the time to conduct maintenance actions so that the expected total cost per time unit can be minimized. To verify the efficiency of the model, some numerical examples are solved with a genetic algorithm, and validation is conducted for the solutions. Finally, sensitivity analyses are performed on the critical parameters.