Zmaj was born in Novi Sad, Serbia, on 24 November 1833. He finished elementary school in the town, and secondary school in Preßburg (today Bratislava), later studying in Ofenpesth (Budapest), Prague and Vienna. In 1870, he returned to Novi Sad to work as a doctor, motivated by the fact that his wife and children were suffering from tuberculosis. His family was an old and noble family. In his earliest childhood he showed a great desire to learn by heart the Serbian national songs which were recited to him, and even as a child he began to compose poems.
His father, who was a highly cultivated and wealthy man, gave him his first education in his native city. After this he went to Ofenpesth, Prague, and Vienna, and in these cities he finished his studies in law. This was the wish of his father, but his own inclinations prompted him to take up the study of medicine. He then returned to his native city, where a prominent official position was offered him, which he accepted; but so strong were his poetical instincts that a year later he abandoned the post to devote himself entirely to literary work.
His literary career began in 1849, his first poem being printed in 1852, in a journal called Srbski Letopis ("Serbian Annual Review"); to this and to other journals, notably Neven and Sedmica, he contributed his early productions. From that period until 1870, besides his original poems, he made many translations to Serbian from Hungarian of works by Sándor Petőfi and János Arany, two of the greatest Hungarian poets, from Russian of the works of Lermontov, as well as from German of several German and Austrian poets. In 1861 he edited the comic journal, Komarac ("The Mosquito"), with Đorđe Rajković, and in the same year he started the literary journal, Javor, and to these papers he contributed many poems.
In 1861, he married, and during the happy years that followed he produced his admirable series of lyrical poems called Đulići, which probably remain his masterpiece. In 1862, greatly to his regret, he discontinued his beloved journal, Javor, a sacrifice which was asked of him by Svetozar Miletić, who was then active on a political journal, in order to insure the success of the latter. Politically engaged, he sympathized with the ideas of the United Serbian Youth, a movement which attracted a number of influential figures in Serbian public life in the period of the 1860s to 1870s. These include the politicians and writers Jevrem Grujić (1826–1895), Jovan Ilić (1823–1901), Svetozar Marković, Sava Grujić, the historians Stojan Novaković, Milovan Janković (1828–1899), Vasa Pelagić (1833–1899), and the political writer Vladimir Jovanović.
In 1863, he was elected director of the Tekelianum, at Ofenpesth (Budapest). He now renewed the study of medicine at the university, and took the degree of doctor of medicine. Meanwhile he did not relax his literary labors. He also devoted himself greatly to education of Serbian youth. During his stay in Ofenpesth he founded the literary society, Preodnica, of which he was president, and to which he devoted a large portion of his energies. In 1864 he started his famous satirical journal, "Zmaj" ("The Dragon"), which was so popular that the name became a part of his own. In 1866, his comic play "Šaran" was given with great success. Since 1870, Zmaj has pursued his profession as a physician. He was an earnest advocate of cremation, and has devoted much time to the furtherance of that cause.
The end of the poet's long life was saddened by domestic sorrows. The loss of his wife in 1872 was followed by another great pain of losing the only child who outlived her mother, out of his five children. How much these misfortunes affected him is plainly perceptible from the deeply sad tone of the poems which immediately followed. In 1873 he started another comic journal, the Žiža. During the year 1877 he began an illustrated chronicle of the Russo-Turkish War, and in 1878 appeared his popular comic journal, Starmali. During all this period he wrote not only poems, but much prose, including short novels, often under an assumed name. The best of these is probably Vidosava Brankovićeva. In that period he published a great many charming little poems for children. He died on 1 June 1904.
His country mourned him with almost royal pomp, and his remains, after lying in state followed to the ceremony of Sremska Kamenica by a vast cortège, including the royal princes and all the great officers of the state.