Staying at Savatthi. Then King Ajatasattu of Magadha, the son of Queen Videha, raising a fourfold army, marched toward Kasi against King Pasenadi Kosala. King Pasenadi heard, "King Ajatasattu of Magadha, the son of Queen Videha, they say, has raised a fourfold army and is marching toward Kasi against me." So King Pasenadi, raising a fourfold army, launched a counter-attack toward Kasi against King Ajatasattu. Then King Ajatasattu & King Pasenadi fought a battle, and in that battle King Pasenadi defeated King Ajatasattu and captured him alive.
The thought then occurred to King Pasenadi: "Even though King Ajatasattu has wronged me when I have done him no wrong, still he is my nephew. What if I, having confiscated all his elephant troops, all his cavalry, all his chariots, & all his infantry, were to let him go with just his life?" So King Pasenadi — having confiscated all his elephant troops, cavalry, chariots, & infantry — let King Ajatasattu go with just his life.
Then in the early morning, a large number of monks, having put on their robes and carrying their bowls & outer robes, went into Savatthi for alms. Having gone for alms in Savatthi, after the meal, returning from their alms round, they went to the Blessed One and, on arrival, having bowed down to him, sat to one side. As they were sitting there, they [reported these events to the Blessed One].
Then, on realizing the significance of that, the Blessed One on that occasion spoke these verses:
See also: SN 3.14; Mv 10.2.3-20; Dhp 69.