In real-world manufacturing systems, it is inevitable to encounter imperfect raw materials and generate defective nished products. In order to cope with these practical problems, this paper studies a manufacturer that orders raw materials from an external source (supplier) and, then, produces a nished product. The raw materials contain imperfect quality items; in addition, the production system is defective. The imperfect raw materials are sold after the screening process, while the defective nished products go under a further rework process. It is also assumed that the defective rate of a machine is a random variable, resulting in three possible cases regarding the occurrence of backordering shortage. The aim is to determine economic order/production lot sizes for each case in such a way that the total cost of the system is minimized. The optimal closed-form solution is derived for each case separately. Moreover, the applicability of the proposed manufacturing model is illustrated via a numerical example.