Vileišis was born in Mediniai, near Pasvalys. In 1892 he graduated from the Šiauliai Gymnasium. During 1892-1894, he studied physics and mathematics at Saint Petersburg University. Later he transferred to the study of law, graduating in 1898. As a student he began contributing to the newspapers "Varpas" ("The Bell") and "Ūkininkas" ("The Farmer"). From 1896 to 1898 he was a member of the Social Democratic Party of Lithuania. After returning to Lithuania, he began practicing law and joined the "12 Apostles" organization, dedicated to defending the right to use the Lithuanian language in print, which was banned at the time. In 1902 he participated in the creation of the Lithuanian Democratic Party.