According to the Mishna (115b), if a flood threatens to kill two animals and the owner of the one that is worth less money goes and saves the more valuable animal, he will only get paid for his efforts – he will not be reimbursed for the value of his animal. If, however, the owner of the more valuable animal agreed beforehand to pay him for his animal, then the owner will be obligated to fulfill the agreement.
In our Gemara, R Kahane asked Rav whether the owner of the more valuable animal will be obligated to fulfill such an agreement in the event that the less valuable animal did not drown, but managed on its own to climb out of the river on the other side. Rav replied that he received a gift from heaven – i.e. that the owner of the less valuable animal will receive payment in any case.
To support this ruling, the Gemara tells the story of Rav Safra who was traveling through the desert with a caravan. When they saw that a lion was tracking the group, everyone took turns leaving a donkey out at night for the lion to eat. On the night that it was Rav Safra’s turn to leave a donkey, the lion did not eat it and Rav Safra took it back for himself.
Although lions ordinarily attack wild animals, on occasion they follow a caravan traveling through the desert (e.g. between Syria and Babylon). The lion (or lions) would then attack the caravan at night, aiming at the pack animals – ordinarily donkeys. In order to avoid such attacks and possible injury or death to the people in the caravan, it was common practice to leave a less valuable animal in a place where the lion could get to it easily, thus protecting the people and the more valuable animals. After eating a large animal like a donkey, the satiated lion would not attack until it was hungry, so it is possible that a night might go by with no attack whatsoever.