The point here is that perfect love for Allah and His Messenger necessarily entails doing what He loves. Thus, the hadith recorded by al-Tirmidhī states:
“Whoever loves for Allah’s sake, hates for Allah’s sake, gives for Allah’s sake, and withholds for Allah’s sake has perfected his faith.”
When a person’s love and hatred—which are acts of the heart—and his giving and withholding—which are bodily acts—are all for Allah’s sake, this indicates the perfection of his love for Allah and, consequently, the perfection of his faith. Perfect faith means that all devotion is for Allah: worshipping Allah alone, without any partner. Worship encompasses perfect love and complete humility. Love is the source of all voluntary actions, and every living being necessarily has love and hatred. Thus, when someone loves those whom Allah loves and hates those whom Allah hates, this indicates the soundness of faith in his heart. Yet this may grow stronger or be weakened by the soul’s opposing appetites and desires. This becomes evident when giving away wealth, which provides the means of sustaining oneself. When his love, giving, and withholding are all for Allah’s sake, this indicates the perfection of faith both inwardly and outwardly.
The root of polytheism among the polytheists—those who divided their religion and became sects—is their taking rivals whom they love as they love Allah. As the Most High says:
“Among people are those who take others besides Allah as equals, loving them as they love Allah.”
As for someone whose love and hatred are for Allah’s sake—who loves only for Allah’s sake, hates only for Allah’s sake, gives only for Allah’s sake, and withholds only for Allah’s sake—this is the state of the foremost among Allah’s close servants, as al-Bukhārī narrated