The aim of this study is to localize the electrode of the deep brain stimulation with three dimensional magnetic field measurements by applying the dipole fitting approach. The deep brain stimulation electrode was positioned successively at five increasing depths with well-known positions in a cylindrical head phantom and the magnetic field distribution was measured with a fluxgate magnetometer around the phantom. At each measuring point, the total magnetic field was measured by rotating the sensor in all three orthogonal directions. Finite element method was used to model the volume conduction of the phantom with its exact dimensions and electromagnetic simulations were performed to calculate the magnetic field distribution at the same measuring points around the phantom. The dipole fitting approach was then used to localize the position of the electrode by means of minimizing the normalized root mean square error between measured and calculated data. The results show an average localization accuracy of less than 1 mm over all performed measurements for both near surface and deep positions. Small deviations in the results can be explained by the measuring accuracy of the used fluxgate sensor. It can be concluded that the deep brain stimulation electrode can be precisely localized by three dimensional magnetic field measurements by using an accurate head volume conduction model and by applying the dipole fitting approach. The presented results are intended as preparatory work for real magnetic field measurements with patients implanted with deep brain stimulation electrodes.