This paper integrates production, maintenance, and quality for an imperfect process in a multi-period multi-product capacitated lot-sizing context. The production system is modeled as an imperfect machine, whose the status is considered to be either in-control or out-of-control. When the machine is out of control, it produces a fraction of nonconforming items. During each period, this machine is inspected and imperfect preventive maintenance activities are simultaneously performed to reduce its age, proportional to the preventive maintenance level. The objective is to minimize the total cost, while satisfying the demand for all products. Our optimization model allows for a joint selection of the optimal values of production plan, and the maintenance policy, while taking into account quality related costs. A solution algorithm is developed and illustrative numerical examples are presented. It is found that the increase in PM level leads to reductions in quality control costs. Furthermore, if the cost of performing PM is high to the point where it is not compensated for by reductions in the quality related costs, then performing PM is not justifiable. Finally, using non-periodic preventive maintenance with the possibility of different preventive maintenance levels may result in an improvement of the total cost.