We study the long term orbital evolution of a terrestrial planet under the gravitational perturbations of a giant planet. In particular, we are interested in situations where the two planets are in the same plane and are relatively close. We examine both possible configurations: the giant planet orbit being either outside or inside the orbit of the smaller planet. The perturbing potential is expanded to high orders and an analytical solution of the terrestrial planetary orbit is derived. The analytical estimates are then compared against results from the numerical integration of the full equations of motion and we find that the analytical solution works reasonably well. An interesting finding is that the new analytical estimates improve greatly the predictions for the timescales of the orbital evolution of the terrestrial planet compared to an octupole order expansion. Finally, we briefly discuss possible applications of the analytical estimates in astrophysical problems.