The Judge Advocate General Corps (or JAG, also known as Starfleet Justice Division) was a division of the United Federation of Planets Starfleet responsible for legal matters concerning Starfleet personnel, including courts martial. They were also responsible for assigning legal representatives to officers during a tribunal held over actions of personnel convicted of crimes.
Rana Desai was the senior JAG officer assigned to Starbase 47 in 2265, responsible for matters within the Taurus Reach. Under her supervision were several Starfleet lawyers, including Lieutenant Holly Moyer and Commander Peter Liverakos. (VAN novel: Harbinger)
Lieutenant Areel Shaw was a JAG officer assigned to Starbase 11 in 2267, who served as prosecutor in the court martial against Captain James T. Kirk. (TOS episode & Star Trek novelization: Court Martial)
In 2269, after the Talin incident, Lieutenant Junior Grade Alise Chavez was assigned as the legal representative to Nyota Uhura during her trial where she was dishonorably discharged from Starfleet. (TOS novel: Prime Directive)
Phillipa Louvois was the JAG officer who presided over the investigation into the loss of the USS Stargazer in 2353, and ruled on the legal standing of Lieutenant Commander Data in 2365. (TNG episode: "The Measure of a Man")
Rear Admiral Bennett was the head of the Judge Advocate General's Office in 2373, and accepted Richard Bashir's guilty plea following the revelation that he had his son Julian illegally subjected to genetic enhancement. (DS9 episode: "Doctor Bashir, I Presume")
Following the capture of Tellarite criminal Sakal by William T. Riker and Beverly Crusher, the JAG office had to determine which of seven aggreived systems to extradite him to. (TNG short story: "'Til Death")
In 2387, Jean-Luc Picard hired retired JAG Commander Jonathan Ezor to represent Picard in a preliminary enquiry regarding Picard's role in the deposing of President Min Zife. (TNG novel: Collateral Damage)