How do i set a object with particles to the background and keep another object in front in composition?
Assuming your rendered image has an Alpha channel then simply change the last Add node in the chain to ‘Mix’ and use the Alpha as the Fac. This will mix between your shapceship and the stars based on the alpha.

Note that if you don’t have an alpha (if you haven’t rendered with transparancy enabled) then you can use the Depth as a filter instead as it will be very high for points on the background behind your spaceship (1000000000 or similar - effectively ‘infinity’) and much lower for points on it - pass the Depth through a Greater Than maths node to compare it with, say, 10000000 and the output of that can be used effectively as an alpha.



This resulted in a final solution (from @IvanVujacic) as follows :