1640s, "an unprincipled popular orator or leader; one who seeks to obtain political power by pandering to the prejudices, wishes, ignorance, and passions of the people or a part of them," ultimately from Greek demagogos "popular leader," also "leader of the mob," from dēmos "people, common people" (originally "district," from PIE *da-mo- "division," from root *da- "to divide") + agogos "leader," from agein "to lead" (from PIE root *ag- "to drive, draw out or forth, move").
In a historical sense from 1650s, "a leader of the masses in an ancient city or state, one who sways the people by oratory or persuasion." Often a term of disparagement since the time of its first use (in Athens, 5c. B.C.E.). Form perhaps influenced by French démagogue (mid-14c.).
Indeed, since the term demagogos explicitly denotes someone who leads or shepherds the demos, the eventual use of this word as the primary epithet for a political panderer represents a virtual reversal of its original meaning. The word demagogos in fact implies that the people need someone to lead them and that political power, at least in part, is exercised appropriately through this leadership. [Loren J. Samons II, "What's Wrong With Democracy," University of California Press, 2004]