Goodman Brown breaks the spell simply by profession of faith. His faith must be genuine, and because it is genuine, he is able to break the spell. It is from crying out to his wife to resist the evil one that the spell is broken.
At the beginning of the story he has copious faith in the goodness of the townspeople and especially in Faith his fiancee. Thinking to ride the wings of her goodness to heaven. At the end of the story however he has lost all that faith and believe everybody to be be evil within.