This problem is most easily done in polar coordinates. In polar coordinates, the Newtonian gravity is given by $$\mathbf{g} = -\frac{GM}{r^2} \mathbf{\hat{r}}$$
Applying Newton's Second Law in polar coordinates gives two differential equations: one radial and one angular: $$\ddot{r} - r \dot{\theta}^2 = -\frac{GM}{r^2} \\ r \ddot{\theta} + 2 \dot r \dot \theta = 0$$$$\ddot{r} - r \dot{\theta}^2 = -\frac{GM}{r^2} \tag {1}$$ $$r \ddot{\theta} + 2 \dot r \dot \theta = 0 \tag{2}$$
By substitutingMultiplying $u = 1/r$ and re-expressing the above equations in terms of$(2)$ by $u$$r$, it can be shownwe observe that $$\frac{\text{d}^2u}{\text{d} \theta^2} + u= \frac{GM}{h^2}$$ where$r^2 \dot \theta = h$ is a constant. This is really just a result of conservation of angular momentum, as there is no force in the angular direction. $h$ is nothing more than the specific angular momentum per unit mass of the orbiting body.
By substituting $u = 1/r$ into $(1)$ and $(2)$ and solving, it can be shown that $$\frac{\text{d}^2u}{\text{d} \theta^2} + u= \frac{GM}{h^2}$$ This can then be solved to obtain$$r=\frac{h^2}{GM (1+e \cos (\theta - \theta_0))}$$ where $e$ is the eccentricity.
This is the equation we were looking for: a conic section. $e =0$ gives a circle, $0 \lt e \lt 1$ gives an ellipse, $e=1$ gives a parabola, and $e \gt 1$ gives a hyperbola.