Where does the energy used to fight gravity go?

I am confused (and I think you may be confused) about whether you are asking about energy or momentum. However the momentum aspects are simple. Let's assume:

  • all the fuel ejected by the spacecraft hits the star;
  • the spacecraft and star are initially momentarily at rest in some inertial frame, and all velocities are measured with respect to this frame;
  • Newtonian gravitation;
  • all collisions inelastic (fuel & spacecraft stick to the star on collision);
  • everything happens along a line, so I will use scalars when I mean vectors.

Let the masses be:

  • spacecraft, without fuel, $m_s$;
  • fuel $m_f$;
  • star $M$;

Then the total momentum in the initial state is trivially $0$.

Final state 1: spacecraft and all its fuel hits the star. Final velocity of the combined star, spacecraft & fuel is $V = 0$ by conservation of momentum.

Final state 2: spacecraft escapes to infinity, asymptotic final velocity of spacecraft $v$, of star + fuel $V$. By conservation of momentum:

$$v m_s + V(M + m_f) = 0$$

& hence

$$V = -v\frac{m_s}{M + m_f}$$

& it's as simple as that.

Note that in the second case I am computing the asymptotic velocities: the velocities after the spacecraft has escaped to infinity. However, in fact, once all the fuel has hit the star the expression is good at any time after that, although the two velocities change over time of course.