If there are units from both sides at the end of combat, what happens?

If both players have units remaining at a battlefield at the end of combat, the attacking units are recalled to their base, and the defender retains the battlefield.