Traditional theistic religions are often defended on the basis that they teach believers to love. It's true that they typically include ideals about loving both God and humanity, but it shouldn't be assumed that the two are always and necessarily compatible. On the contrary, other teachings common to religions around the world can in fact set the two at odds with one another such that the more one loves God, the more difficult it can be for them to also love humanity.
The critical issue here is the concept of purity. Just about every religion studied thus far has included some type of doctrine about purity and holiness on the one side and impurity or pollution on the other. Purity and holiness are valued above everything else; impurity and pollution are to be avoided at all costs — and once acquired, people are to do whatever is necessary to shed them. Purity and holiness ultimately have their origins in God (who is perfectly pure and demands purity from us) while impurity separates one from God.
Impossible Purity
Unfortunately for humanity, it is impossible for us to really be pure and holy. We might achieve more or less purity thorough our actions and thoughts, but in the end only God is truly pure and truly holy. What this can mean is that the more one values purity, the more one will be inclined to see humanity as polluted and unworthy. The more polluted and impure humanity is, the harder it is to maintain any positive feelings towards them, much less something like love
In Thus Spake Zarathustra, Friedrich Nietzsche depicts such attitudes:
Zarathustra went down the mountain alone, no one meeting him. When he entered the forest, however, there suddenly stood before him an old man, who had left his holy cot to seek roots. And thus spake the old man to Zarathustra: [...]
"Why," said the saint, "did I go into the forest and the desert? Was it not because I loved men far too well? Now I love God: men, I do not love. Man is a thing too imperfect for me. Love to man would be fatal to me."
At the end of this exchange, the "old man" is described as a "saint," indicating that he isn't just any pious believer. We should probably conclude that this old man is living out in the forest alone for the same reason that so many Christian ascetics did in the past: to separate themselves from the pollution that fills human society. By removing themselves from as much human contact as possible they hoped to be able to interact more directly with God due to their increased purity and holiness.
Saints, Fanatics, and Terrorism
Not all ascetics and saints who lived like this made the move from loving God and purity to hating humanity and impurity, but it's not much a leap and it may have been a specter that haunted the minds of far more than we realize. It's also not a problem which has disappeared today. Wherever we see religious oppression, violence, and terrorism, we can usually find in the background some basic ideas the importance of maintaining and enforcing religious purity and holiness.
For the sake of purity and holiness outsiders must be kept outside and held down in a second-class status if they insist on hanging around. For the sake of purity and holiness women must not be allowed equality alongside men — after all, women are even more impure than men and must not be allowed to pollute men. In the name of purity and holiness crusades against infidels and unbelievers must be launched regardless of the cost in lives or treasure. When unreal abstractions about what is "pure" are placed ahead of the messy lives of human beings, humans frequently lose — and lose their lives. Messily.
Putting purity above humanity can occur in secular contexts, and we have seen this occur for example with communists who have killed colleagues for failing to correct adhere to "pure" and "true" communist doctrine. It is far more common, however, to see it in religion where "God" is already an extreme abstraction created by humans on the basis of human ideals but then placed beyond the scope of humanity itself. It is, in fact, arguable that one of the key problems with religions generally is their insistence on placing human abstractions above real human needs.

