When Shri Krishna and Arjuna were scouting for land to set-up their separate kingdom of Indraprastha, they were approached by Agnidev. Agnidev was suffering because of being constantly fed Ghee during King Swetaki’s twelve-year long yajna conducted under supervision of rishi Durvasa.
Agnidev was told by Brahmadev that only treatment of his suffering is when he consumes the entire Khandavavan along with all its inhabitants. Agindev tried that many times but every time he tried to burn Khandavavan, Indra started the rain because Indra’s friend Takshak also lived in the same forest.
Agnidev asked for help from Shri Krishna and Arjuna. The land that gets cleared from Khandava dahan will be suitable for setting up Indraprashtha.
Arjuna asked Agnidev, if he can help him with suitable weapons, they would not mind helping him.
Agnidev gave Arjuna a divine golden chariot with Shri Hanuman’s flag pulled by four divine horses. He borrowed Gandiva along with two quivers with an inexhaustible number of arrows from Varun dev and gave it to Arjuna.
Thus, Arjuna came in possession of Gandiva, which he returned to Varun dev before him mahaprayana.