In this paper, a new algorithm for system identification based on frequency response is presented. In this method, given a set of magnitudes and phases of the system transfer function in a set of discrete frequencies, a system of linear equations is derived which has a unique and exact solution for the coefficients of the transfer function provided that the data is noise-free and the degrees of the numerator and denominator are selected correctly. If the data is corrupted with (bounded) noise, then the answer is no longer unique and an acceptable transfer function is one that has a frequency response with a noise bound that covers the noisy data. To find one of these acceptable results, a new performance index is defined as "the least squares distance in the coefficient space". By minimizing this index, an initial transfer function is obtained which passes optimally through the noisy data. Then, using the so-called dynamic programming technique, the noise is reduced in such a way that at each step the resulting transfer function is pushed toward one of the acceptable noisefree systems. An illustrative example shows the effectiveness of the proposed algorithm.