It's a sally battle, so special rules apply. If the battle ends, your units are completely within the walls, all gates are closed, and the enemy still exists on the battlefield, the battle is a draw regardless of casualties. The siege continues. If the enemy withdraws off the battlefield, it's a victory. If the gates aren't closed, then the computer will autocalc the result and you may well lose the fight and the settlement. The besieger can run through gates you open and capture them.

Normally when the time runs out the defender wins. In a sally, you are the attacker.