This paper presents an algorithm for the localisation of partial discharge (PD) sources in power transformers based on the electromagnetic waves radiated by a PD pulse. The proposed algorithm is more accurate than existing methods, since it considers the effects of the reflection, refractions and diffractions undergone by the ultra-high frequency (UHF) signal within the equipment tank. The proposed method uses computational simulations of the electromagnetic waves generated by PD, and obtains the time delay of the signal between each point in the 3D space and the UHF sensors. The calculated signals can be compared with the signals measured in the field, so that the position of the PD source can be located based on the best correlation between the simulated propagation delay and the measured data. The equations used in the proposed method are defined as a 3D optimisation problem, so that the binary particle swarm optimisation algorithm can be used. To test and demonstrate the proposed algorithm, computational simulations were performed. The solutions were sufficient to identify not only the occurrence of defects, but also the winding and the region (top, centre or base) in which the defect occurred. In all cases, an accuracy of greater than 15 cm was obtained for the location, in a 180 MVA three-phase transformer.