In the Tibetan mystical world, however, the Fifth Dalai Lama's dramatic and almost effortless rise to power is not seen as a play of mundane political dynamics. A deeper cause lay in a promise made a hundred years earlier, after the Second Dalai Lama passed away and was traveling in the afterworld. He had almost decided not to reincarnate in Tibet, but instead to take birth in another world, where his bodhisattva services would be more beneficial. Suddenly the great guru Padma Sambhava, who had come to Tibet in the eighth century and built Tibet's first monastery, appeared to the Dalai Lama in a vision and requested that he continue to incarnate in Tibet. Padma Sambhava gave the Dalai Lama the Dharma Protector Pehar (i.e., Nechung) as his personal assistant. In addition, he proclaimed that if the Dalai Lama continued to work in Tibet, he would rise to the position of spiritual and temporal head of the land, where he would be in a position to bring great benefits that would continue for centuries. The Great Fifth became spiritual and temporal leader of Tibet exactly a hundred years after the Second experienced this vision and prophesy.
-The Fourteen Dalai Lamas, A Sacred Legacy of Reincarnation by Glenn H. Mullin pg. 201
I looked this up. The Second Dalai Lama died in 1542. In 1642 Gushi Khan defeated a proxy of the Karma Kagyu and the last of the Dalai Lama's rivals. The Khan then gave the Dalai Lama rulership over Tibet.