AUG. Since there are two commandments, the love of God and the love of our neighbor, on which hang the Law and the Prophets, not without reason does Scripture put one for both; sometimes the love of God; as in that, We know that all things work together for good to them that love God; and sometimes the love of our neighbor; as in that, All the law is fulfilled in one word, even in this, You shall love your neighbor as yourself. And that because if a man love his neighbor, it follows therefrom that he loves God also; for it is the selfsame affection by which we love God, and by which we love our neighbor, save that we love God for Himself, but ourselves and our neighbor for God's sake.
This is from Aquinas's Catena Aurea; it condenses a passage from Augustine's De Trinitate Book VIII, Chapter 7. The full text (except for the very last part of Aquinas's summary, which is from the end of Chapter 8):
For as there are two commandments on which hang all the Law and the prophets, love of God and love of our neighbor; not without cause the Scripture mostly puts one for both: whether it be of God only, as is that text, "For we know that all things work together for good to them that love God;" and again, "But if any man love God, the same is known of Him;" and that, "Because the love of God is shed abroad in our hearts by the Holy Ghost which is given unto us;" and many other passages; because he who loves God must both needs do what God has commanded, and loves Him just in such proportion as he does so; therefore he must needs also love his neighbor, because God has commanded it: or whether it be that Scripture only mentions the love of our neighbor, as in that text, "Bear one another's burdens, and so fulfill the law of Christ;" and again, "For all the law is fulfilled in one word, even in this, You shall love your neighbor as yourself;" and in the Gospel, "All things whatsoever ye would that men should do to you, do ye even so to them; for this is the Law and the prophets." And many other passages occur in the sacred writings, in which only the love of our neighbor seems to be commanded for perfection, while the love of God is passed over in silence; whereas the Law and the prophets hang on both precepts. But this, too, is because he who loves his neighbor must needs also love above all else love itself. But "God is love; and he that dwells in love, dwells in God." Therefore he must needs above all else love God.
There is a similar line of reasoning in Augustine's Tractates on the Gospel of John:
Think not then, my brethren, that when the Lord says, "A new commandment I give unto you, that you love one another," there is any overlooking of that greater commandment, which requires us to love the Lord our God with all our heart, and with all our soul, and with all our mind; for along with this seeming oversight, the words "that you love one another" appear also as if they had no reference to that second commandment, which says, "You shall love your neighbor as yourself." For "on these two commandments," He says, "hang all the law and the prophets." But both commandments may be found in each of these by those who have good understanding. For, on the one hand, he that loves God cannot despise His commandment to love his neighbor; and on the other, he who in a holy and spiritual way loves his neighbor, what does he love in him but God?