The gemara says that when someone sees another do an aveira, even if there aren't two witnesses so you can't testify on him in a court, you are allowed to hate him. The gemara proves this point from the pasuk that describes חמור שונאך רובץ תחת משאו - the donkey of your enemy crouched under its load. What type of enemy is the Torah speaking about? The gemara says that it can't be someon that you hate for no good reason because that would be a violation of לא תשנא את אחיך בלבבך, therefore it must be speaking about an enemy that you hate because you saw him doing an aveira.
The gemara implies that the ONLY way that one can have a Jewish enemy, yet not be in violation of לא תשנא את אחיך בלבבך would be when you see him do an aveira and are therefore allowed to hate him. There is a big machlokes in the Rishonim regarding the parameters of לא תשנא and why the Torah specifies בלבבך - in your heart. Rabbeinu Yona (sha'arei teshuva 3:39) and the Ramban both say that all hatred is included. The only reason that the Torah writes בלבבך is because that is more common, but the issur would be violated even if he expressed his hatred. However, the Rambam (Hil. Deios 6:10) writes that the only violation is when one hides the hatred in his heart, but when one expresses the hatred they would not be in violation. The Rambam seems to be contradicted by the gemara because the gemara indicates that all hatred would be included. According to the Rambam the gemara should have said that there can be an enemy who you hate for no good reason, but as long as you tell him that you hate him you would avoid the violation of לא תשנא. How will the Rambam learn this gemara?
I think that the Rambam would say that the context of the gemara is defining the term שונאך of the Torah. The Torah is speaking in a context where you would be going to help him unload his donkey. This would be a clear display of love. The very act of helping him would hide the animosity and hatred that you feel for him. Therefore, it could not be speaking about someone you hate for no reason because that would violate לא תשנא את אחיך בלבבך, since the actions of helping him give him the impression that you don't hate him.