In this study, a new method for the analysis of harmonic components in the power system based on a deep learning (DL) framework is introduced. In the proposed method, both amplitudes and phases of the harmonic components can be estimated accurately, unlike most of the research work in the literature, which usually focus on estimating amplitudes only. A convolutional neural network (CNN) structure is used to estimate the phases and amplitudes of harmonics, although CNN is usually used for classification. It has been shown that the proposed DL-based method can satisfactorily estimate both amplitudes and phases of the power system harmonics inside a 20-ms window and this makes the proposed method suitable for possible real-time applications, such as active power filtering of the harmonics. It has also been shown that the proposed method is robust to fundamental frequency changes. Experiments on carefully-generated data sets to reflect the power system behaviour show that the proposed method demonstrates remarkably good performance in terms of estimation accuracy, especially for time-varying frequency cases. Average error for the amplitude estimation is obtained as 0.21% and that for the phase is 9 degrees, which outperforms the other compared analyses methods in cases of fundamental frequency variations.