Once you've killed these attackers, you have a new goal. Usually, I'd end up with 8–9, using my hero to tank most of the damage and then moving him back when surrounded while my ranged units sniped enemies and then retreated as well. If you end the battle with fewer than eight units, I'd recommend you just restart.
You can take this battle wherever you want (there's a friendly priest who can heal you in the city itself), but the main goal should be to preserve units. As you start, you'll get a small group of units with a hero very shortly, you'll face an attack on the city.