Sahih Muslim Book 19, Hadith Number 4448.

Chapter : The battle of Ahzab or Khandaq (the tribes or the ditch).

It has been narrated (through a still different chain of transmitters) by Anas that the Companions of Muhammad (may peace be upon him) were chanting on the day of the Battle of the Ditch:

We are those who have sworn allegiance to Muhammad (And made a covenant with him) to follow Islam as long as we live.

Hammad is not sure whether Anas said: “Ala’l-Islam” or, “Ala’l-Jihad”. And the Holy Prophet (may peace be upon him) was chanting:

O God, the real good is the good of the Hereafter, so forgive Thou the Ansar and the Muhajirs.