He was born in Groningen, the son of the banker Klaas Mesdag and his wife Johanna Wilhelmina van Giffen. Mesdag was encouraged by his father, an amateur painter, to study art. He married Sina van Houten in 1856, and when they inherited a fortune from her father, Mesdag retired from banking at the age of 35 to pursue a career as a painter.
In 1880 he received a commission from a Belgian company to paint a panorama giving a view over the village of Scheveningen on the North Sea coast near The Hague . With the help of Sina and students he completed the enormous painting (Panorama Mesdag)— 14 m high and 120 m around — by 1881. However, the vogue for panoramas was coming to an end, and when the company operating it went bust in 1886, Mesdag purchased the painting at auction and thereafter funding its operating losses from his own pocket.
He joined the art society of The Hague (the Pulchri Studio) and in 1889 was elected chairman. In 1903 he gave his house at Laan van Meerdervoort and his collection of paintings to the Netherlands; the house is now the Museum Mesdag.