Namo te Buddha vīratthu, vippamuttosi sabbadhi; Sambādhapaṭipannosmi, tassa me saraṇaṁ bhavā!
Homage to you, O Buddha, O Hero, you are liberated in all ways; I have met with an obstruction, so be my refuge!
This is a short gāthā said to have been recited, on different occasions, by both Candimā and Sūriya (the gods of the moon and the sun, respectively) after being seized by the Asura-Lord, Rāhu.
In the Candima Sutta (SN 2.9), we are told of a time when the lunar devaputta Candimā was assailed by a violent being named Rāhu. Rāhu is an asura - specifically, an "asurinda" (Asura-Lord). In Indian mythology, asuras are in perpetual warfare with the devas. Accordingly, both lunar and solar eclipses are associated with this conflict, wherein the scenes from the two suttas play out time and time again, with Rāhu once more seizing either of the celestial devas, temporarily obscuring their light. If you'd like to learn more about asuras, please see my essay on the topic.
While in the grasp of the Asura-Lord, Candimā recited the above gāthā while "recollecting the Blessed One" (bhagavantaṁ anussaramāno). Hearing this, the Buddha spoke in verse to Rāhu: "In the Tathāgata, the Arahant, Candimā has gone for refuge; Rāhu, release the moon. The Buddhas have compassion for the world." The Buddha's intervention so thoroughly filled Rāhu with fear that he immediately let Candimā go and fled to see Vepacitti, the foremost of the Asura-Lords.
Vepacitti, in verse, asked his companion to explain why he arrived so suddenly and so visibly terrified. Rāhu, likewise in verse, explained that his head would have split into seven pieces if he hadn't released Candimā after being "chanted over with the Buddha's verse" (buddhagāthābhigītomhi).
The Sūriya Sutta (SN 2.10) immediately follows the Candima Sutta in the Saṁyutta Nikāya. It plays out in exactly the same way, with the exception that the Buddha's address to Rāhu is longer, containing one additional gāthā: "Dispeller of darkness and gloom, the shining one, the blazing disk; Rāhu, do not swallow him as he moves through the sky! Rāhu, release my child, Sūriya!" The Buddha is often associated with solar motifs in various epithets and metaphors, so it's fitting that the version of this story involving the sun would be longer.
Traditionally, the two suttas are recited in their entirety as protective charms (paritta). In this context, they are known as the Canda Paritta and the Sūriya Paritta. Personally, I only recite the single gāthā, since those are the words used by the gods in their plea for help.
The commentaries introduce details which make this story more interesting. Within the moon and sun alike, there can be found a beautiful vimāna - a divine palace which arises spontaneously as the result of good kamma. The lunar vimāna is made of a precious gemstone, with a silver exterior, and it is always cool inside and out. The solar vimāna is made of gold, with a crystal exterior, and it is always hot inside and out.1 Candimā and Sūriya live inside of their respective vimānas, accompanied by many lesser devas.2 Seeing the splendor of the moon and the sun fills Rāhu with envy, inspiring him to stand in the path of their orbit (since, in Buddhist cosmology, the moon and sun rotate around the world's center-point, Mount Sineru). When the moon or the sun draw near, he tries to obscure it by blocking it with his hands, covering it with his open mouth or his tongue, or engulfing it entirely by closing his mouth around it. This frightens the gods who live in the interior palace so much that they cry out in terror. Rāhu poses no real threat, however, as he is completely powerless to stop the orbit of the moon and the sun. He must resort to covering it as best he can while moving through the sky.3
Notes
[1] These details come from the commentary to the Aggañña Sutta (DN-a 27), cited by Punnadhammo Mahathero in "The Buddhist Cosmos: A Comprehensive Survey of the Early Buddhist Worldview."
[2] This comes from the commentary to the Suriya Sutta (SN-a 2:10), again cited by Punnadhammo Mahathero.
[3] ibid.