The Battle of the Ramganga or Battle of the Rahib in December 1020 AD was a decisive battle, during Mahmud of Ghazni's second invasion of the Doab. Ghaznavid forces defeated the Hindu Shahi army of Trilocanapala at the upper course Ramganga River known as River Ruhut near Afzalgarh. Trilocanapala entrenched on the eastern bank with infantry and elephants to block the crossing. After detecting Trilocanapala's nighttime plan to flee downstream, Mahmud sent eight swimmers across on inflated skins; they repelled Hindu archers and five elephants, secured the bank, and enabled the full army to cross without loss. At dawn the Ghaznavids surprised and routed Trilocanapala's camp after a day-long battle. Trilocanapala escaped wounded; his army suffered heavy casualties, prisoners, and flight. Mahmud captured rich spoils. Trilocanapala was later assassinated by his followers while joining Chandela ruler Vidyadhara