Security forces are trying to retake the town where militants raised their flag at an army base.