Gravitational energy is the energy that is possessed by the object in the gravitational field by the virtue of its position. The potential energy at a certain height is equal to the work required to bring the mass from infinity with constant velocity to that height.
The gravitational potential energy near a planet is negative since gravity does positive work.
U=−GmMr
This form of gravitational potential energy is used in calculating the escape velocity.