Estonia was a dominion of Denmark during Middle Ages. Between 1206 and 1645 Denmark for several periods of time either held claims to, or ruled over, parts of present-day Estonia.

Denmark rose as a great military and merchant power in the 12th century. It had an interest to end the occasional Estonian and Couronian pirate attacks that threatened its Baltic trade. Danish fleets made attacks against Estonia in 1170, 1194, and 1197. In 1206 King Valdemar II and archbishop Andreas Sunonis made a raid to Ösel (Saaremaa) island. The islanders were forced to submit and the Danes built a fortress there, but they found no volunteers to man it. They burned it down themselves and left the island. However, they laid a claim to Estonia as their possession, which was recognized by the pope.

In 1219 Valdemar gathered a fleet of hundreds of ships against the Estonians, led by the archbishop, bishops and the army of Rugians under their prince Wizlav. They landed in Lyndanisse (Tallinn) harbor in the province of Revelia (Revala, Rävälä, later merged into Harria province) in northern Estonia. According to a legend, the first ever flag of Denmark fell from sky and helped the Danes to win the battle against Revelians and Harrians. The date of the battle, June 15th, is the annual holiday of Valdemarsdag in present Denmark.