Moctezuma II (c. 1466 – 29 June 1520) 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). During his reign the Aztec Empire reached its greatest size.

In 1517, Moctezuma received the first news of ships with strange warriors having landed on the Gulf Coast near Cempoallan and he dispatched messengers to greet them 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 November 8, 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 had shifted towards the Spaniards who now held Motecuzoma as a prisoner in his own palace. As this shift in power became clear to Moctezuma's subjects, the Spaniards became increasingly unwelcome in the capital city, and in June 1520, hostilities broke out, culminating in the massacre in the Great Temple, and a major uprising of the Mexica against the Spanish.

More Info: en.wikipedia.org