Banu Thaqif had been long standing rivals of the Quraysh. They saw the Quraysh’s defeated as an opportunity to attack and seize control of Mecca for themselves.
In response, Prophet Muhammad called all Muslims to battle and led an army of 12,000 against them. Banu Thaqif’s side had over 20,000.
Banu Thaqif setup an ambush in the Valley of Hunain, making most Muslims flee. However, Prophet Muhammad was able to rally the troops and counter the assault.
During the battle, some tribes had begun killing women and children, and were later strongly rebuked for it by Prophet Muhammad, formalizing the prohibition against killing non-combatants and civilian rights.
Podcast version: podcast.lifeofprophetmuhammad.com