As a village, it was founded some time in the 16th century as a single house of a forest ward, certain Hajno, who was one of the royal officers protecting the Białowieża Forest. In 1589 whole forest became a private property of the royal court and the number of forest workers settled in the area started to grow. However, the forest protection (it was most probably the first forest reserve in the world) prevented the area from economical growth and so the village was limited to a number of wooden huts at the western end of the forest. It mostly shared the history of other similar settlements in the area, including Białowieża itself.
After the Partitions of Poland of late 18th century the area was annexed by Kingdom of Prussia in 1795. After the fall of the Duchy of Warsaw and the end of Napoleonic Wars it was annexed to Imperial Russia. The tsarist authorities abolished the forest protection, but the development of the area did not start. Since most of the foresters to work in the forest took part in the November Uprising of 1831 against Russia (500 out of 502 in total), their posts were abolished, people sent to Siberia and protection of the forest was harmed. The village practically ceased to exist. Protection was reintroduced in 1860 and the village was repopulated with Russian officials. In 1888 it became part of the tsarist domains.
Between 1894 and 1906 the village was linked with the world by a railroad linking Bielsk Podlaski and Siedlce with Wołkowysk. Hajnówka became a minor transport hub and in 1900 a road was built between Białowieża and Bielsk Podlaski. During World War I, in 1915, the area was captured by Germany. Protection of the forest was abolished and the new authorities started fast economical exploitation of the area. Because of its nodal position, Hajnówka became a seat of two lumber-mills, wood spirit distillery and a major train station for 90 kilometres of narrow gauge railways built through the forest.
In 1919, during the early stages of the Polish-Bolshevik War, the area was handed over to Poland by local Ober-Ost commander. The predatory exploitation of the forest was put to an end and all German-built factories in the area became nationalised. After the war, some of them were rented to a British company of "The Century European Timber Corporation". However, in early 1920s the agreement was broken and the wood industry factories came back under state control, while the Terbenthen factory was sold to a private owner. Since then their growth started - and so the village started to grow. Hard work, but also decent salaries in wood processing plants attracted many settlers from various parts of Poland. The initial conglomerate of wooden huts, barracks, tents and narrow, wood-paved streets turned into a town.
A Catholic church was built for the local population and soon the factories and the state financed three schools, a boarding school of wood industry, post office, two cinemas and a bank. Jewish inhabitants built a synagogue and in 1925 the Orthodox inhabitants organised a chapel in a private flat. Out of approximately 4000 inhabitants approximately 70% were Poles from all parts of the country, while the rest was composed of Jews, Germans and Ukrainians. Also, the soldiers of the Belarusian division of general Stanisław Bułak-Bałachowicz were interned there after the war and finally were allowed to settle in the area, which added Belarusians and Russians to the ethnic mixture.
By the end of 1930's the four factories of Hajnówka had 1947 workers altogether and were significantly expanded. The state financed construction of several hundred small houses for the workers and the town grew rapidly. Also, the town attracted many notable Polish architects of the epoch to build new buildings in modernist style. However, the progress was stopped by the Polish Defensive War of 1939 and the outbreak of World War II. In the effect of the Nazi-Soviet Alliance, the town was annexed by the Soviet Union. The factories were dismantled and sent to Russia while a large part of the inhabitants were in 1940 arrested by the NKVD and imprisoned in the Soviet Gulag system. In 1941 the town got under German occupation, which ended in 1944. During the fights the town was severely bombed, which added to the destruction of the city. All in all, until July 18, 1944, more than 700 inhabitants of Hajnówka lost their lives, the factories were robbed and then demolished while the train station and parts of the town centre were levelled by aerial bombardment.
Despite harsh conditions and infrastructural losses, life returned to Hajnówka very quickly. This attracted new settlers as well as pre-war inhabitants of the area, so the town quickly recovered. Also, the narrow streets were mostly rebuilt. In 1951 the town (until then formally a village) was granted with city rights and between 1954 and 1975 it even served as a seat of a powiat. Hajnówka has 8 schools as well as 4 churches (Catholic and Eastern Orthodox), 2 hospitals, sewer system, swimming pool. Train and bus links were established. In 2005 the local timber factory expanded its production plant (area-17500m2), one of the largest in Europe. It is very modern and used for manufacturing of furniture, mainly to be exported to Western Europe.