In line with the Qur'anQur'an 42:15 ↗فَلِذَٰلِكَ فَٱدۡعُۖ وَٱسۡتَقِمۡ كَمَآ أُمِرۡتَۖ وَلَا تَتَّبِعۡ أَهۡوَآءَهُمۡۖ وَقُلۡ ءَامَنتُ بِمَآ أَنزَلَ ٱللَّهُ مِن كِتَٰبٖۖ وَأُمِرۡتُ لِأَعۡدِلَ بَيۡنَكُمُۖ ٱللَّهُ رَبُّنَا وَرَبُّكُمۡۖ لَنَآ أَعۡمَٰلُنَا وَلَكُمۡ أَعۡمَٰلُكُمۡۖ لَا حُجَّةَ بَيۡنَنَا وَبَيۡنَكُمُۖ ٱللَّهُ يَجۡمَعُ بَيۡنَنَاۖ وَإِلَيۡهِ ٱلۡمَصِيرُ
To this go on inviting, and be upright as you were commanded, and do not follow their inclinations, and say, “I believe in whatever Book God has sent down, and I was commanded to judge between you equitably. God is our Lord and your Lord. We have our deeds, and you have your deeds. Let there be no quarrel between us and you. God will bring us together, and to Him is the ultimate return.”
The verse has the messenger say he was commanded to be just among people, matching his reply that he would be wretched if he were not just.
In line with the Qur'anQur'an 16:90 ↗۞إِنَّ ٱللَّهَ يَأۡمُرُ بِٱلۡعَدۡلِ وَٱلۡإِحۡسَٰنِ وَإِيتَآيِٕ ذِي ٱلۡقُرۡبَىٰ وَيَنۡهَىٰ عَنِ ٱلۡفَحۡشَآءِ وَٱلۡمُنكَرِ وَٱلۡبَغۡيِۚ يَعِظُكُمۡ لَعَلَّكُمۡ تَذَكَّرُونَ
God commands justice, and goodness, and generosity towards relatives. And He forbids immorality, and injustice, and oppression. He advises you, so that you may take heed.
The verse states that God commands justice, the duty the messenger affirms when told to be fair in dividing the spoils.