Security officials say gun battles raged for several hours before the attackers fled .