Matejko was born on 24 June 1838, in the Free City of Kraków. His father, Franciszek Ksawery Matejko () (born 1789 or 13 January 1793, died 26 October 1860), a Czech from the village of Roudnice, was a graduate of the Hradec Králové school who later became a tutor and music teacher. He first worked for the Wodzicki family in Kościelniki, Poland, then moved to Kraków, where he married the half-German, half-Polish Joanna Karolina Rossberg (Rozberg). Jan was the ninth child of eleven children. He grew up in a kamienica building on Floriańska Street. After the death of his mother in 1845, Jan and his siblings were cared for by his maternal aunt, Anna Zamojska.