[fee to secure services] mid-15c., "act of keeping for oneself, an authorized retention (of dues, etc.)," an agent noun from retain (v.), or perhaps from or influenced by French retenir, infinitive used as a noun. Meaning "a retaining fee, fee paid to an attorney or barrister to secure his services" is from 1818. The general sense of "sum paid to secure special services" is from 1859.
early 14c. (mid-13c. in Anglo-Latin), "one appointed by another to act in his place," from Old French atorné "(one) appointed," past participle of aturner "to decree, assign, appoint," from atorner "to assign," literally "to turn to" (see attorn). The sense is of "one appointed to represent another's interests."
In English law, a private attorney (attorney in fact) was one appointed to act for another in business or legal affairs (usually for pay); an attorney at law or public attorney was a qualified legal agent in the courts of Common Law who prepared the cases for a barrister, who pleaded them (the equivalent of a solicitor in Chancery). So much a term of contempt in England that it was abolished by the Judicature Act of 1873 and merged with solicitor.
Johnson observed that "he did not care to speak ill of any man behind his back, but he believed the gentleman was an attorney." [Boswell]
In U.S., barrister is not used and the general designation became properly attorney and counselor at law; when presenting a case in court, simply counselor. The double -t- is a mistaken 15c. attempt to restore a non-existent Latin original, perhaps by influence of legal Latin form attornare.
mid-14c., "one whose profession is to plead cases in a court of justice," a technical term from Roman law, from Old French avocat "barrister, advocate, spokesman," from Latin advocatus "one called to aid (another); a pleader (on one's behalf), advocate," noun use of past participle of advocare "to call (as witness or adviser), summon, invite; call to aid; invoke," from ad "to" (see ad-) + vocare "to call," which is related to vox (genitive vocis) "voice" (from PIE root *wekw- "to speak").
Also in Middle English as "one who intercedes for another," and "protector, champion, patron." Feminine forms advocatess, advocatrice were in use in 15c.; advocatrix is from 17c. Old English glossed Latin advocatus with þingere (see thing).