At a young age he witnessed the Kraków revolution of 1846 and the 1848 siege of Kraków by the Austrians, the two events which ended the existence of the Free City of Kraków. His two older brothers served in these battles, under General Józef Bem; one died and the other was forced into exile. Matejko attended St. Ann's High School, but he dropped out in 1851 because of poor grades. From his earliest days Matejko showed artistic talent, but had great difficulty with other academic areas. He never mastered a foreign language. Despite that, and because of his exceptional skill, he studied at the School of Fine Arts in Kraków from 1852 to 1858. His teachers included Wojciech Korneli Stattler and Władysław Łuszczkiewicz. He selected historical painting as his specialization, and finished his first major work, "Tsars Shuyski before Zygmunt III" ("Carowie Szujscy przed Zygmuntem III"), in 1853 (he would return to this topic in a year before his death, in 1892). During this time, he began exhibiting historical paintings at the Kraków Society of Friends of Fine Arts (starting with 1855). His seminal project for his graduation in 1858 was "Sigismund I the Old ennobles the professors of the Jagiellonian University" ("Zygmunt I nadaje szlachectwo profesorom Uniwersytetu Jagiellońskiego").