Lawyer is a general term for a person who gives legal device and aid and who conducts suits in court.
An attorney or, more correctly, an attorney-at-law, is a member of the legal profession who represents a client in court when pleading or defending a case. In the US, attorney applies to any lawyer. In the UK, those who practice law are divided into barristers, who represent clients in open court and may appear at the bar, and solicitors, who are permitted to conduct litigation in court but not to plead cases in open court. The barrister does not deal directly with clients but does so through a solicitor. The word attorney comes from French meaning ‘one appointed or constituted’ and the word’s original meaning is of a person acting for another as an agent or deputy. A solicitor would be the UK equivalent of the US attorney-at-law. Counsel usually refers to a body of legal advisers but also pertains to a single legal adviser and is a synonym for advocate, barrister, counselor, and counselor-at-law.
As to the abbreviation ‘Esq.’ for ‘Esquire’ used by some lawyers, it has no precise significance in the United States except as sometimes applied to certain public officials, such as justices of the peace. For some reason, lawyers often add it to their surname in written address. However, it is a title that is specifically male with no female equivalent, so its use by lawyers should fade away.