Gandiva was the bow of Arjuna in the Mahabharata. Arjuna received the Gandiva bow from Agni. Legend has it that Agni gave Arjuna the bow for helping in performing the Khandava Dahanam or the burning of the Khandava forest. There is an interesting story as to how Arjuna came to receive the Gandiva bow from Agni.
Once there was a king named Shvetaki. He conducted several types of yajnas for several years and this filled the kingdom with smoke. The yajna place was continuously under smoke and the Rishis found it difficult to even breathe. They all left the place.
This did not deter Shvetaki who decided to conduct another yajna for 12 years but none of the Rishis were ready to take part in it.
Shvetaki then prayed to Shiva for a solution and He gave him Durvaasas as the priest for the yajna.
Durvaasas continued the yajna for 12 years pouring unlimited materials into Agni.
Agni was now overfed and could no longer take anymore food. His brilliance started to fade and this started causing imbalance in the universe.
He then approached Brahma for a solution.
Brahma said that his indigestion will be cured if he burns down the Khandava forest which has become the abode of those people practicing Adharma.
He immediately started burning down the forest but Indra created heavy rain and put out the fire. Takshaka a friend of Indra was residing in the forest so the came to his help.
Agni again approached Brahma who said that he will succeed in burning down the forest when Nara-Narayana visits the place.
He waited for the right opportunity.
One day Arjuna and Sri Krishna arrived at the Khandava forest. Agni disguised as a saint approached them knowing that they are Nara-Narayana.
Agni gave Arjuna the Gandiva Bow to achieve his mission.
Krishna agreed to help Agni. When Agni started burning down the Khandava forest, Indra started the rains but it was blocked by Arjuna using a canopy created out arrows.
Agni also gave Arjuna, an arrow case which would be never empty, a chariot with monkey flag and four horses adorned with golden chains.
Gandiva bow originally belonged to the Supreme Being, it was then received by Prajapati, then Indra, then Soma, then Varuna and then Agni.
When Arjuna was approaching the Swargarohana period – going to heaven – Agni approaches Arjuna to return the Gandiva. Agni then returns the Gandiva bow to Varuna.