In the Srimad-Bhagavatam, there are verses describing how Arjuna employed a mystic incantation to travel to various celestial realms, as mentioned in the following verses:
एवं शपति विप्रर्षौ विद्यामास्थाय फाल्गुन: । ययौ संयमनीमाशु यत्रास्ते भगवान् यम: ॥ ४२ ॥
विप्रापत्यमचक्षाणस्तत ऐन्द्रीमगात् पुरीम् । आग्नेयीं नैऋर्तीं सौम्यां वायव्यां वारुणीमथ । रसातलं नाकपृष्ठं धिष्ण्यान्यन्यान्युदायुध: ॥ ४३ ॥ ततोऽलब्धद्विजसुतो ह्यनिस्तीर्णप्रतिश्रुत: । अग्निं विविक्षु: कृष्णेन प्रत्युक्त: प्रतिषेधता ॥ ४४ ॥
While the wise brāhmaṇa continued to heap insults upon him, Arjuna employed a mystic incantation to go at once to Saṁyamanī, the city of heaven where Lord Yamarāja resides. Not seeing the brāhmaṇa’s child there, Arjuna went to the cities of Indra, Agni, Nirṛti, Soma, Vāyu and Varuṇa. With weapons at the ready he searched through all the domains of the universe, from the bottom of the subterranean region to the roof of heaven. Finally, not having found the brāhmaṇa’s son anywhere, Arjuna decided to enter the sacred fire, having failed to keep his promise. But just as he was about to do so, Lord Kṛṣṇa stopped him and spoke the following words.
The quoted paragraph suggests that Arjuna possessed a certain Vidya (knowledge or mystical power) that enabled him to journey to the abodes of Yama and other celestial beings.
Additionally, the sumamry part of the chapter also confirms that despite Arjuna's search throughout the fourteen worlds, he could not locate the brāhmaṇa’s son. This suggests that Arjuna indeed possessed the ability to traverse all the fourteen lokas through his Vidya. I am not sure whether he travelled with physical body or subtle body.
As the brāhmaṇa profusely derided Arjuna, the warrior set off for the abode of Yamarāja, the king of death. But Arjuna did not find the brāhmaṇa’s son there, and even after searching throughout the fourteen worlds he could find no trace of the infant.
However, it is not explicitly mentioned in this excerpt how Arjuna acquired this Vidya. Therefore, I am seeking information from the scriptures about the specific origin of Arjuna's Vidya — whether through rigorous spiritual practice (sadhana), boon, or any other means. Is there any scriptural reference that explicitly explains how Arjuna obtained this capability?