The details of the story are explained in the succeeding paragraphs.
Arjuna, after the death of his son , Abhimanyu, took a severe pledge that he would kill Jayadratha before the end of the next day battle (day 14th of the Mahabharata war). As part of that pledge, Arjuna also vowed that if he failed in killing Jayadratha, he would offer his self to the fire God (Agni) and end his life.
And during the night, Arjuna offered his prayers to God, remembering the mantras given to him by Maharishi Vyasa and in that process fell asleep.
And during his sleep,Lord Sri Krishna, having Garuda on his banner, appeared in Arjuna’s dreams. Having worshipped Lord Sri Krishna, Arjuna discussed the plans for killing Jayadratha in the battle, the next day.And he was advised to recall the mantra for using the Pashupatatra,as that would ensure victory against Jayadratha.
Surrounded in battle as he will be by all of them and by all the great car-warriors, how shall he obtain a sight, O Krishna, of the wicked ruler of the Sindhus? My vow will not be accomplished, O Kesava! How can a person like me live, having failed to accomplish his vow?
The bird-bannered Krishna hearing this cause of Partha's grief, touched water and sat with face turned to the east. And then that hero, of eyes like lotus leaves, and possessed of great energy, said these words for the benefit of Pandu's son who had resolved upon the slaughter of the ruler of the Sindhus, 'O Partha, there is an indestructible, supreme weapon of the name of Pasupata. With it the god Maheswara slew in battle all the Daityas! If thou rememberest it now, thou shalt then be able to slay Jayadratha tomorrow.
As Arjuna had forgotten the mantra for invoking Pashupatastra, he started meditating on Lord Bhava (Lord Shiva) during the Brahma Muhurta, as per the advice of Lord Sri Krishna.
If it is unknown to thee (now), adore within thy heart the god having the bull for his mark. Thinking of that god in thy mind, remember him, O Dhananjaya! Thou art his devotee. Through his grace thou shalt obtain that rich possession.' Hearing these words of Krishna, Dhananjaya, having touched water, sat on the earth with concentrated mind and thought of the god Bhava.
Then Arjuna saw himself journeying through the sky with Kesava (Lord Sri Krishna) and reached the mountain where Lord Shiva was.
After he had thus sat with rapt mind at that hour called Brahma of auspicious indications, Arjuna saw himself journeying through the sky with Kesava. And Partha, possessed of the speed of the mind, seemed to reach, with Kesava, the sacred foot of Himavat and the Manimat mountain abounding in many brilliant gems and frequented by Siddhas and Charanas. And the lord Kesava seemed to have caught hold of his left arm. And he seemed to see many wonderful sights as he reached (those place).
Lord Sri Krishna and Arjuna then prayed to Lord Shiva, for obtaining the Pasupatastra.
To thee that art called Brahmachakra, to thee that art called Sarva, Sankara, and Siva! We bow to thee that art the lord of all great beings! We bow to thee that hast a thousand heads, to thee that hast a thousand arms, to thee that art called Death! To thee that hast a thousand eyes, a thousand legs? To thee whose acts are innumerable! We bow to thee
whose complexion is that of gold, to thee that art cased in golden mail, to thee that art ever compassionate to thy devotees! O lord, let our wish be accomplished.'
Lord Shiva asked them to bring the celestial bow and arrow from a nearby celestial lake.
And as they approached the snakes, conversant as they were with the Vedas, they uttered the hundred stanzas of the Veda, to the praise of Rudra, bowing the while with their sincere souls unto Bhava of immeasurable power. Then those two terrible snakes, in consequence of the power of those adorations to Rudra, abandoned their snake-forms and assumed the forms of a foe-killing bow and arrow. Gratified (with what they saw), Krishna and Arjuna then seized that bow and arrow of great effulgence.And those
high-souled heroes then brought them away and gave them unto the illustrious Mahadeva.
And Lord Shiva taught Arjuna the procedure for invoking the Pashupatastra again.
Beholding the manner of his seizing the handle of the bow and drawing the string and placing of his feet, and hearing also the Mantras uttered by Bhava, the son of Pandu, of inconceivable prowess, learnt everything duly.
Reference:-Mahabharata Book:7, Drona Parva, Abhimanyu–Badha Parva