Ainaži[a][b] (Estonian: Heinaste; Livonian: Āinast) is a Latvian port town by the Gulf of Riga in the Baltic Sea.
Historically, the German language variants of the same name (e.g., Haynasch), were used in most written records from the late Middle Ages until the first half of the 20th century.
In 1864, Krišjānis Valdemārs sponsored the first naval school in Livonia (today Latvia), training young Estonian and Latvian farmers to become ship captains for free.
By World War I, Ainaži was the fourth-largest port in all of Latvia and chief in Vidzeme, overtaking neighboring Salacgrīva.
Though the port was partially rebuilt after the war, Ainaži was overshadowed by nearby Pärnu, and lost its fish-processing factory to Salacgrīva.
After Latvia's independence was restored in 1991, a wind turbine was built in Ainaži, as well as a customs house on the Estonian border.
In addition, its location at the Latvia-Estonia border on the A1 road (Latvia), which is part of the Via Baltica international highway, favors transit/transport industries.