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"].
Sense evolved in English and French to "having the character or manners of one of noble rank or birth," varying according to how those were defined. From mid-13c. in English as "gracious, kind" (now obsolete), manners prescribed for Christian or chivalrous nobility. From late 13c. as "courteous, polite, well-bred, charming;" c. 1300 as "graceful, beautiful." Meaning "mild, tender; easy; not harsh" (of animals, things, persons) is from 1550s. Older sense remains in gentleman, and compare gentile (adj.), an alternative form which tends to keep the Biblical senses of the Latin word (though gentle in Middle English sometimes meant "pagan, heathen"), and genteel, which is the same word borrowed again from French. From 1823 as "pertaining to the fairies."
early 14c., "one who holds an official post, one entrusted with a responsibility or share of the management of some undertaking" (originally a high office), from Old French oficier "officer, official" (early 14c., Modern French officier), from Medieval Latin officiarius "an officer," from Latin officium "a service, a duty" (see office).
In Middle English also "a servant, a retainer of a great household; an official at court" (late 14c.). From late 14c. as "a military retainer," but the modern military sense of "one who holds a commission in the army or navy" is from 1560s. Applied to petty officials of justice from 16c.; U.S. use in reference to policemen is from 1880s.
The phrase officer and a gentleman in reference to one having the qualities of both is by 1762 and was standard language in British court-martial indictments ("behaviour infamous and scandalous such as is unbecoming the character of an officer and a gentleman").
The words 'officer and gentleman,' though in general to be understood as one single and indivisible term, appear not to be so used here. The misbehaviour, entailing on it the penalty declared by this article, must be such, as I understand it, as to implicate, in the first place, the officer; that is, it must arise in some sort out of his office; and affect incidentally only, the character of the gentleman. It must be such a misconduct, as must necessarily dissever what should ever be indivisible, the consideration of the officer from the gentleman. It must be of that decisively low, humiliating, and debasing kind, as to lay prostrate the honour of the gentleman, in the degradation of the officer. [Capt. Hough and George Long, "The Practice of Courts-Martial," London, 1825]