Gravitational force - both

it pulls the earth inward as inertia causes it to move forward. The earth’s gravity keeps the moon in orbit around it in the same way. Because the earth is closer to the moon than the Sun is, Earth exerts a stronger force of gravity on the nearby moon and keeps it in orbit. ................
................