The aim of this dissertation thesis is the optimization of manufacturing processes using the tools of a digital factory. The aim of the research is the implementation of the digital twin into manufacturing systems and their subsequent optimization based on the data obtained from the digital twin. The digital twin is considered a key technology for connecting the virtual and physical worlds. The development of modern production technologies contributes to the successful introduction of Industry 4.0 principles into industrial processes. The case study for the creation of a digital twin consists of an analysis of the current state of the production line for machining engine blocks, which represents the physical layer of the digital twin. The virtual layer involves creating a simulation model of the production line. Communication between the physical layer and virtual layer is provided by the information processing layer, whose task is to collect, archive and implement data into the virtual layer from the physical layer. The created digital twin of the production line was verified and validated and behaves like a real production line. Based on the outputs provided by the digital twin, it was possible to optimize the production line and increase its production.