The origins of the Amazon rainforest are deeply tied to the geological birth of the South American continent and the rising of the Andes Mountains roughly 15 to 20 million years ago. Before this, the Amazon River actually flowed westward toward the Pacific Ocean. As the South American tectonic plate collided with the Nazca plate, the Andes rose and blocked the river's path, creating a massive inland sea in the Amazon basin. Eventually, the water worked its way through the bedrock to the east, and the modern Amazon River was born, flowing toward the Atlantic. The sediment-rich waters flowing from the mountains created fertile conditions for a vast variety of plant life to flourish. During the various Ice Ages, the forest expanded and contracted, but its core survived as a "refuge" of biodiversity, eventually evolving into the 6.7 million square kilometer ecological powerhouse that plays a critical role in the world's climate today.