Achieving high workpiece accuracy is the long-term goal of machine tool designers. There are many causes for workpiece inaccuracy, with thermal errors being the most common. Indirect compensation (using prediction models for thermal errors) is a promising strategy to reduce thermal errors without increasing machine tool costs. The modelling approach uses transfer functions to deal with this issue; it is an established dynamic method with a physical basis, and its modelling and calculation speed are suitable for real-time applications. This research presents compensation for the main internal and external heat sources affecting the 5-axis machine tool structure including spindle rotation, three linear axes movements, rotary C axis and time-varying environmental temperature influence, save for the cutting process. A mathematical model using transfer functions is implemented directly into the control system of a milling centre to compensate for thermal errors in real time using Python programming language. The inputs of the compensation algorithm are indigenous temperature sensors used primarily for diagnostic purposes in the machine. Therefore, no additional temperature sensors are necessary. This achieved a significant reduction in thermal errors in three machine directions X, Y and Z during verification testing lasting over 60 hours. Moreover, a thermal test piece was machined to verify the industrial applicability of the introduced approach. The results of the transfer function model compared with the machine tool’s multiple linear regression compensation model are discussed.