A two-dimensional CCD beam quality diagnositic system has been built up, by means of which the beam quality factor M2 for Nd:hlass laser in free-running and Q-switching operatins has been measured. The diagnostic system has been tested and verified, the measurement results are correct.