It worked because Thanos loved Gamora - and you can tell Thanos loved Gamora because it worked.
Gamora is a less reliable indicator of Thanos' love than the Soul Stone. Thanos would not be the first parent (biological or adopted) whose "tough love" alienated the child, despite having genuine feelings of love for that child... the fact that she hates him does not preclude him loving her.
following the Snapocalypse, where Thanos met a young Gamora in a Soul Stone-tinted setting, seems to indicate that the Soul Stone has access to Thanos' inner thoughts, and perhaps to Gamora's as well
which suggests that the Soul Stone had the information it needed to truthfully judge whether Thanos met its requirement of sacrificing a loved one. Lacking any reason to believe the Stone's test was anything other than what was stated, we must conclude that Thanos loved Gamora.