Here's a pretty decent summary of Avicenna's cosmology (McGinnis):
Avicenna's modal ontology yet again provides him with a neat solution to this problem of medieval cosmology. From the necessary Existent there emanantes fro Avicenna the Intellect associated witht eh outermost celestial sphere. This Intellect must itself already be composite, for it is something possible in tiself but necessary through another. Now, continues Avicenna, when this Intellect contemplates the Necessary Existent, there emanates from that first Intellect another Intellect-let this second Intellect be the one associated with the fixed stars. In addition to contemplating the Necessary Existent, the first Intellect also contemplate itself, but, as has already been seen, it si something composite consisting of its won possible existence and the necessary existence it has from another. Thus, according to Avicenna's own unique emanative scheme, when the first Intellect contemplates itself as something merely possible in itself, there emanates from it a certain celestial body, whereas when it contemplates itself as necessary through another, it emanates that celestial body's soul. This process continues at the level of the second Intellect. Now, however, the second Intellect contemplates its relation the first Intellect and the Necessary Existent. This emanative process continues cascading downward with new Intellects, souls, and clestial bodies being produced until reaches the Active Intellect or Giver of Forms, which is the Intellect that produces the Moon and lunar soul.