Philadelphia lawyer
On September 7, 1717, Hamilton was appointed as attorney-general of Pennsylvania by Governor William Keith. In March 1721, he was called to the provincial council, and he accepted on condition that his duties should not interfere with his practice. Hamilton resigned the office in 1724; that year he traveled to London to oversee the formal approval of William Penn's will on behalf of the Penn family.
When a settler named Cartledge killed a Seneca man in 1722 in an area outside the boundaries of Philadelphia County, tension rose between the tribes in the area and the colonists. Colonists feared the Seneca would cause violence unless Cartledge could be brought to trial. A new Court Act was deemed necessary and created under the supervision of Hamilton, as Attorney-General, and the Chief Justice, David Lloyd. Lloyd's older laws were consolidated into the Judiciary Act of 1722, which was passed by Governor Keith on May 22, 1722. One feature allowed the Chief Justice to act as a justice of the peace anywhere in the colony if conditions called for it, a clear response to the Cartledge situation. As the murdered man was a Seneca, colonists feared the powerful Iroquois Confederacy might retaliate against the colonists for his death. Lloyd prepared to prosecute Cartledge. But the Iroquois wrote to Lloyd on July 30, 1722, urging that Cartledge be forgiven. At once the Assembly ordered one hundred pounds set aside for expenses and one hundred pounds for gifts. They authorized Hamilton as Attorney-General, Judge Hill, and a Mr. Norris to be a committee to visit the Five Nations.
In 1727, Hamilton was appointed prothonotary of the Supreme Court, Master of the Rolls, and Recorder of Philadelphia. He was elected to the Pennsylvania Provincial Assembly from Bucks County in the same year, chosen speaker in 1729, and re-elected annually until his retirement in 1739, with the exception of a single year, 1733.
The crowning glory of Hamilton's career was his defense of John Peter Zenger in 1735, which he undertook pro bono. Zenger was a printer in New York City. In his newspaper, Zenger had asserted that judges were arbitrarily displaced, and new courts were erected, without the consent of the legislature, by which trials by jury were taken away when a governor was so disposed. The attorney-general charged him with the crime of seditious libel, and Zenger's lawyers James Alexander and William Smith, objecting to the legality of the judge's commissions, were stricken from the list of attorneys. At this point, no New York attorneys could take the case. The merchant Mary Spratt Alexander suggested to her husband James Alexander that he ask his colleague Andrew Hamilton whom he was in regular correspondence with – and who was outside of the reach of influence by the judge – to come to New York to defend Zenger. Mary Alexander then traveled to Philadelphia to interview Hamilton and provide him with the facts of the case. It is thought that she and her husband were early investors of the New York Weekly Gazette.
Hamilton feared that the advocate, who had subsequently been appointed by the court, might be overawed by the bench, at the head of which was Chief Justice De Lancey, a member of the governor's council. He voluntarily went to New York and appeared in the case on Zenger's behalf. He admitted that Zenger had printed and published the article but advanced the doctrine, novel at the time, that the truth of the facts in the alleged libel could be set up as a defense. He said that in this proceeding, the jury were judges of both the law and the facts.
The offer of evidence to prove the truth of Zenger's statements was rejected, but Hamilton appealed to the jury to find or acknowledge from the evidence of their daily lives that the contents of the defendant's article were true. He argued that the definition of criminal libel, which didn't require the accusations to be false, came from the hated Star Chamber. His eloquence secured a verdict of "not guilty".
The people of New York and the other colonies hailed the verdict with delight, since it insured free discussion of the public conduct of public officials. Gouverneur Morris referred to Hamilton as "the day-star of the American Revolution." The common council of New York passed a resolution thanking him for his services, and presented him with the freedom of the city. In addition, a group of prominent residents contributed to the production of a 5½-ounce gold box that was presented to Hamilton as a lasting mark of their gratitude to him. His fame spread to England, an account of the trial passing through four editions there within three months.
On May 12, 1732, Thomas Penn, John Penn and Richard Penn, as the proprietors of Pennsylvania, signed an order to create a commission. This order was directed to prominent figures in the colonial Province of Pennsylvania and Philadelphia, including Hamilton, as well as Governor Gordon, Isaac Norris, Samuel Preston, and James Logan, Esquires, and to the gentlemen James Steel and Robert Charles. The commission, which was to be made up of at least three or more of these individuals, was given full power on behalf of the proprietors for the "running, marking, and laying out" of any boundary between Pennsylvania and Maryland. This was in accordance to the agreement signed between the Penn brothers and Charles Calvert, 5th Baron Baltimore on May 10, 1732.
From 1736 to his death in 1741, Hamilton was the mentor of young Benjamin Chew, who later became Attorney General and Chief Justice of Pennsylvania. Hamilton was for many years a trustee of the general loan-office, the province's agency for issuing paper money. In 1737 he was appointed judge of the vice-admiralty court by Deputy Governor George Thomas, the only office he held at the time of his death.