mid-14c., from Medieval Latin barbarinus (source of Old French barbarin "Berber, pagan, Saracen, barbarian"), from Latin barbaria "foreign country," from Greek barbaros "foreign, strange, ignorant," from PIE root *barbar- echoic of unintelligible speech of foreigners (cf. Sanskrit barbara- "stammering," also "non-Aryan," Latin balbus "stammering," Czech blblati "to stammer").
Greek barbaroi (n.) meant "all that are not Greek," but especially the Medes and Persians. Originally not entirely pejorative, its sense darkened after the Persian wars. The Romans (technically themselves barbaroi) took up the word and applied it to tribes or nations which had no Greek or Roman accomplishments. The noun is from late 14c., "person speaking a language different from one's own," also (c.1400) "native of the Barbary coast;" meaning "rude, wild person" is from 1610s.