Title: Mexico
Content:  in the last volume of Bernardino de Sahagún's General History of the Things of New Spain.  When the Spaniards arrived, the ruler of the Aztec empire was Moctezuma II, who after a delay allowed the Spanish to proceed inland to Tenochtitlan. The Spanish captured him, holding him hostage. He died while in their custody and the Spanish retreated from Tenochtitlan in great disarray. His successor and brother Cuitláhuac took control of the Aztec empire, but was among the first to fall from the first smallpox epidemic in the area a short time later. Unintentionally introduced by Spanish conquerors, among 
Title: Spanish conquest of the Aztec Empire
Content: 1428 – Creation of the Triple Alliance of Tenochtitlan, Texcoco, and Tlacopan ; 1492–93 – Columbus reaches the Caribbean; start of permanent Spanish settlements ; 1493–1515 – Spanish exploration, conquest, enslavement, and settlement in the Caribbean and the Spanish Main ; 1502 – Moctezuma II elected huey tlatoani, emperor [literally: "Great Speaker"] of the Aztec Triple Alliance ; 1503–09 – Moctezuma's coronation conquests ; 1504 – Hernan Cortés arrives in the Caribbean ; 1511– Spanish viceroy in the Caribbean appoints Diego Velázquez to conquer and govern Cuba ; 1510~ Francisco Vazquez de Coronado was born ; 1515 – Texcocan monarch Nezahualpilli dies; Cacamatzin 
Title: Aztecs
Content:  in a smallpox epidemic, although early sources do not give the cause. He was succeeded by Cuauhtémoc, the last independent Mexica tlatoani, who continued the fierce defense of Tenochtitlan. The Aztecs were weakened by disease, and the Spanish enlisted tens of thousands of Indian allies, especially Tlaxcalans, for the assault on Tenochtitlan. After the siege and complete destruction of the Aztec capital, Cuauhtémoc was captured on 13 August 1521, marking the beginning of Spanish hegemony in central Mexico. Spaniards held Cuauhtémoc captive until he was tortured and executed on the orders of Cortés, supposedly for treason, during an ill-fated expedition to Honduras in 1525. His death marked the end of a tumultuous era in Aztec political history.
Title: Spanish conquest of the Aztec Empire
Content:  known to the Spanish conquistadors as Doña Marina, and later as La Malinche. After eight months of battles and negotiations, which overcame the diplomatic resistance of the Aztec Emperor Moctezuma II to his visit, Cortés arrived in Tenochtitlan on 8 November 1519, where he took up residence with fellow Spaniards and their indigenous allies. When news reached Cortés of the death of several of his men during the Aztec attack on the Totonacs in Veracruz, Cortés claims that he took Motecuhzoma captive. Capturing the cacique or indigenous ruler was a standard operating procedure for Spaniards in their expansion in the Caribbean, so capturing Motecuhzoma 
Title: Aztecs
Content:  the Pacific to the Atlantic oceans. The empire reached its maximal extent in 1519, just prior to the arrival of a small group of Spanish conquistadors led by Hernán Cortés. Cortés allied with city-states opposed to the Mexica, particularly the Nahuatl-speaking Tlaxcalteca as well as other central Mexican polities, including Texcoco, its former ally in the Triple Alliance. After the fall of Tenochtitlan on 13 August 1521 and the capture of the emperor Cuauhtémoc, the Spanish founded Mexico City on the ruins of Tenochtitlan. From there they proceeded with the process of conquest and incorporation of Mesoamerican peoples into the Spanish Empire. With the destruction of the 
Title: Aztecs
Content:  Moctezuma II Xocoyotzin is known to world history as the Aztec ruler when the Spanish invaders and their indigenous allies began their conquest of the empire in a two-year-long campaign (1519–1521). His early rule did not hint at his future fame. He succeeded to the rulership after the death of Ahuitzotl. Moctezuma Xocoyotzin ( "He frowns like a lord, the youngest child"), was a son of Axayacatl, and a war leader. He began his rule in standard fashion, conducting a coronation campaign to demonstrate his skills as a leader. He attacked the fortified city of Nopallan in Oaxaca and subjected the adjacent region to the empire. An effective warrior, Moctezuma maintained the pace of conquest set by 
Title: Aztecs
Content:  and find out what was happening, and he ordered his subjects in the area to keep him informed of any new arrivals. In 1519, he was informed of the arrival of the Spanish fleet of Hernán Cortés, who soon marched towards Tlaxcala where he formed an alliance with the traditional enemies of the Aztecs. On 8 November 1519, Moctezuma II received Cortés and his troops and Tlaxcalan allies on the causeway south of Tenochtitlan, and he invited the Spaniards to stay as his guests in Tenochtitlan. When Aztec troops destroyed a Spanish camp on the gulf coast, Cortés ordered Moctezuma to execute the commanders responsible for the attack, and Moctezuma complied. At this point, the power balance 
Title: Spanish conquest of the Aztec Empire
Content:  the capital of the Aztec Empire. The fall of Tenochtitlan marks the beginning of Spanish rule in central Mexico, and they established their capital of Mexico City on the ruins of Tenochtitlan. Cortés made alliances with tributary city-states (altepetl) of the Aztec Empire as well as their political rivals, particularly the Tlaxcaltecs and Tetzcocans, a former partner in the Aztec Triple Alliance. Other city-states also joined, including Cempoala and Huejotzingo and polities bordering Lake Texcoco, the inland lake system of the Valley of Mexico. Particularly important to the Spanish success was a multilingual (Nahuatl, a Maya dialect, and Spanish) nahua-speaking woman enslaved by the 
Title: Spanish conquest of the Aztec Empire
Content:  The Aztecs were struck by a smallpox plague starting in September 1520, which lasted seventy days. Many were killed, including their new leader, the Emperor Cuitlahuac. The joint forces of Tlaxcala and Cortés proved to be formidable. One by one they took over most of the cities under Aztec control, some in battle, others by diplomacy. In the end, only Tenochtitlan and the neighboring city of Tlatelolco remained unconquered or not allied with the Spaniards. Cortés then approached Tenochtitlan and mounted a siege of the city that involved cutting the causeways from the mainland and controlling the lake with armed brigantines constructed by the Spanish and transported overland to the lake. The Siege of Tenochtitlan lasted eight months. The besiegers cut off the supply of 
Title: Spanish conquest of the Aztec Empire
Content:  In any event, the population of the city rose en masse after the Spanish attack, which the Spanish did not expect. Fierce fighting ensued, and the Aztec troops besieged the palace housing the Spaniards and Moctezuma. Alvarado and the rest of the Spanish were held hostage by the Aztecs for a month. The nobility of Tenochtitlan chose Cuitláhuac as Huey Tlatoani (Emperor). Cortés ordered Moctezuma to speak to his people from a palace balcony and persuade them to let the Spanish return to the coast in peace. Moctezuma was jeered and stones were thrown at him, mortally wounding him. Aztec sources state the Spaniards killed 

Question: who was the aztec ruler when the spanish arrived?
Answer: Moctezuma II.
emperor Cuauhtemoc.