The motion of a point mass in the J2 problem is generalized to that of a rigid body in a J2 gravity field. The linear and nonlinear stability of the classical type of relative equilibria of the rigid body, which have been obtained in our previous paper, are studied in the framework of geometric mechanics with the second-order gravitational potential. Non-canonical Hamiltonian structure of the problem, i.e., Poisson tensor, Casimir functions and equations of motion, are obtained through a Poisson reduction process by means of the symmetry of the problem. The linear system matrix at the relative equilibria is given through the multiplication of the Poisson tensor and Hessian matrix of the variational Lagrangian. Based on the characteristic equation of the linear system matrix, the conditions of linear stability of the relative equilibria are obtained. The conditions of nonlinear stability of the relative equilibria are derived with the energy-Casimir method through the projected Hessian matrix of the variational Lagrangian. With the stability conditions obtained, both the linear and nonlinear stability of the relative equilibria are investigated in details in a wide range of the parameters of the gravity field and the rigid body. We find that both the zonal harmonic J2 and the characteristic dimension of the rigid body have significant effects on the linear and nonlinear stability. Similar to the classical attitude stability in a central gravity field, the linear stability region is also consisted of two regions that are analogues of the Lagrange region and the DeBra-Delp region respectively. The nonlinear stability region is the subset of the linear stability region in the first quadrant that is the analogue of the Lagrange region. Our results are very useful for the studies on the motion of natural satellites in our solar system.