Between 1173–1175, Khaqani composed odes in honor of the Shirvan victory over the Russians, in which he reports the locations and details of the operations, including the destruction of 73 Russian ships. His personal life at this time was filled with tragedy. He suffered several family bereavements, including the death of his first wife, and his young son, Rashid-al-Din. Khaqani composed elegies lamenting their deaths. About the same time, Khaqani went on a second pilgrimage, after which he retired from court life to settle at Tabriz. According to accounts of him in various biographical works on poets, the date of his death ranges from 1186 to 1199. According to the gravestone in Tabriz, Khaqani died in Shawwal 595, corresponding to July 1199.