Zmaj was born in Novi Sad, which was then part of Batsch-Bodrog County (Kingdom of Hungary, Austrian Empire; today in Serbia), on 24 November 1833. His family was old and noble, and had roots in modern-day North Macedonia. The Jovanovićs lived in Vojvodina as of the 18th century. Zmaj's father Pavle served as the mayor of Novi Sad after the Hungarian Revolution of 1848 and his three brothers were soldiers, government officials and Serbian patriots. In his early childhood he showed a desire to learn by heart the Serbian national songs that were recited to him. As a child he began to compose poems. He finished elementary school in the town, and attended secondary school in Halas and Preßburg (today Bratislava), later studying law in Ofenpesth (Budapest), Prague and Vienna. This was his father's wish but his own inclinations prompted him to take up the study of medicine. Zmaj then returned to his native city, where he accepted prominent official position. A year later, his poetic instincts caused him to leave his job to devote himself entirely to literary work. In 1870, Zmaj returned to Novi Sad to work as a doctor, motivated by the tuberculosis from which his wife and children were suffering.