To accurately obtain the phase distribution of an optical surface under test, the accurate phase extraction algorithm is essential. To overcome the phase shift error, a random two-step phase shifting algorithm, which can be used in the fluctuating and non-uniform background intensity and modulation amplitude, Lissajous ellipse fitting, and least squares iterative phase shifting algorithm (LEF&LSI PSA), is proposed; pre-filtering interferograms are not necessary, but they can get relatively accurate phase distribution and unknown phase shift value. The simulation and experiment verify the correctness and feasibility of the LEF & LSI PSA.