The idea of multiple heavens layered above the earth, usually seven of them, is widespread across the ancient Near East and the traditions descended from it. Its origin is generally traced to Mesopotamian astronomy, where the seven visibly moving bodies, the sun, the moon and the five planets visible to the unaided eye, were each associated with a level or sphere.
In Judaism, seven heavens are described in rabbinic literature, which names them and assigns contents to each (Hagigah 12b), and in apocalyptic works such as 2 Enoch and the Testament of Levi, where a visionary ascends through them in sequence. Paul's reference to a man caught up to "the third heaven" (2 Corinthians 12:2) presupposes a multiple-heaven cosmology without specifying which scheme he has in mind.
In Islam the seven heavens are Qur'anic and mentioned repeatedly (2:29, 65:12, 67:3, 71:15). The narrative of the Prophet's night journey and ascension, the Isra and Mi'raj, has him ascend through them and meet a prophet at each, a sequence developed extensively in hadith and in a large later literature, and among the most frequently represented episodes in Islamic devotional art.
The scheme merged with Greek astronomy in late antiquity, and the Ptolemaic system of concentric spheres carrying the planets, with the sphere of the fixed stars beyond them, became the standard cosmology of the medieval Islamic and Christian worlds. Dante's Paradiso is organised on it, ascending through the spheres of Moon, Mercury, Venus, Sun, Mars, Jupiter and Saturn before the fixed stars and beyond, and it structures a great deal of medieval and early modern imagery.
Two connections are worth drawing out. The association of the number seven with the visible planets is also the origin of the seven-day week and of the ordering of its days by planetary rulers, a derivation that survives in the day-names of the Romance languages and, partially, in English. And the layered heavens were dismantled as physical cosmology over the sixteenth and seventeenth centuries, after which the traditions that had held them divided between reading the scheme figuratively and treating it as of no doctrinal consequence at all. There is very little modern theological investment in the number, and the phrase "seventh heaven" survives in ordinary English long after the cosmology that generated it.