c. 1200, perhaps mid-12c., "well-born man, man of good family or birth," also extended to Roman patricians and ancient Greek aristocrats, from gentle + man (n.); the compound probably is modeled on Old French gentilhomme (the English gentleman itself was borrowed into French in 18c.).
Given specific uses in late Middle English (small gentleman, gentleman-of-arms, gentleman-usher, etc.), hence in England the word often meant any man above the social rank of a yeoman, including the nobility, but it was sometimes restricted to those who bear a coat of arms but not a title; in U.S., "man of property, not engaged in business or a profession" (1789). The English word from the beginning also had a special sense "nobleman whose behavior conforms to the ideals of chivalry and Christianity," and gentleman came to be used loosely for any man of good breeding, courtesy, kindness, honor, strict regard for the feelings of others, etc.
[The Gentleman] is always truthful and sincere ; will not agree for the sake of complaisance or out of weakness ; will not pass over that of which he disapproves. He has a clear soul, and a fearless, straightforward tongue. On the other hand, he is not blunt and rude. His truth is courteous ; his courtesy, truthful ; never a humbug, yet, where he truthfully can, he prefers to say pleasant things. [The Rev. John R. Vernon, "The Grand Old Name of Gentleman," in Contemporary Review, vol. XI, May-August 1869]
Eventually, in polite use, it came to mean a man in general, regardless of social standing. Related: Gentlemen. Gentleman's agreement is first attested 1929. Gentleman farmer recorded from 1749, "A man of means who farms on a large scale, employs hands, and does little or none of the work himself" [Craigie, "Dictionary of American English"].