Al-Ilmam bi-Ahadith al-Ahkam 244
وَعَن ابْن عمر رَضِيَ اللَّهُ عَنْهما: " أَن رَسُول الله ﷺ كَانَ إِذا خرج يَوْم الْعِيد أَمر بالحربة؛ فتوضع بَين يَدَيْهِ؛ فَيصَلي إِلَيْهَا وَالنَّاس وَرَاءه وَكَانَ يفعل ذَلِك فِي السّفر "، فَمن ثمَّ اتخذها الْأُمَرَاء. لفظ مُسلم .
And from Ibn ʿUmar, may Allah be pleased with them both: "When the Messenger of Allah ﷺ went out on the day of ʿEid, he would order the spear, and it would be placed in front of him, and he would pray towards it with the people behind him; and he used to do that while travelling." From that the rulers adopted it. The wording is Muslim's.