Topological W3 gravity is constructed in detail from its definition as topological Yang-Mills theory in two dimensions with the gauge group being a contraction of SL(3, R). The gauge transformation of the Yang-Mills gauge field can be rewritten to resemble that of the spin-2 and -3 gauge fields describing W3 gravity. This fact provides a local parametrization of the moduli space of the flat connections in terms of spin-2 and -3 Beltrami differentials on Riemann surfaces. The variations of the action with respect to the moduli give the stress tensor and the spin-3 W current, and the BRST charge can be expressed in terms of these currents in a way similar to that of W3 gravity. The physical content of the model is briefly discussed.