What does "And when you gaze long into an abyss, the abyss also gazes into you" mean?

A famous Friedrich Nietzsche quote goes, "And when you gaze long into an abyss, the abyss also gazes into you." What did he mean by that? When/where did this quote first appear?

Any help would be greatly appreciated. Thanks!
10 answers 10