The word started to be popular after a movie "Borat: Cultural Learnings of America for Make Benefit Glorious Nation of Kazakhstan" by Sasha Baron Cohen.
The word can be misinterpreted as a Czech greeting which sounds very similar to the Polish one and means the same thing. That happens because Czech and Polish are both quite similar Slavic languages.
However,the expression used by Borat comes from Polish because minority of people in Kazakhstan speaks Polish, and Borat was trying to represent them as well as people speaking Russian in the country, who are in majority.
Interestingly it sounds like an American guy trying to repeat Polish "jak sie masz?" which means "how are you?".
Obviously Poland must be somewhere in Khazakstan...
American guy: "Jagshemash?" What the fuck is that?
how are you? fine, thx