Under the jurisdiction of the Chief of Fleet Operations, the Office of the Judge Advocate General enforced all administrative law within the ranks of Starfleet. The JAG carries out investigations of wrong-doing by Starfleet officers and convenes courts martial when necessary. Although the Judge Advocate General herself is headquartered at Starfleet Command, the JAG maintains offices on all major starbases. Any incident requiring the intervention of the JAG is referred to the nearest local office, though extremely important cases or those involving high-ranking officers are often pulled back to Starfleet Command for the JAG's personal attention.
In addition to upholding Starfleet's Uniform Code of Justice, the JAG investigates and prosecutes cases involving violations of Starfleet's General Orders, the Constitution of the United Federation of Planets, and the laws of Federation member worlds. The Judge Advocate General's office has jurisdiction over any member of Starfleet accused of wrongdoing, even if the violation occurred under local law. Normally, on a member planet, local authorities remand the accused officer to Starfleet's custody, and the officer is tried under the Uniform Code of Justice. On a non-aligned planet, however, this is largely a question of custody; once in an alien jail, it is within the planet's rights to try the accused. Starfleet, however, works hard to convince the planet's government to surrender the accused for court martial proceedings. This isn't always successful, and more than one officer had faced trial on an alien world, under unfamiliar (and sometimes poorly understood) laws. Often, in the case of laws broken on a nonmember world, the JAG office will invite a representative of the local government to observe, or even present evidence.
Most JAG offices retain several highly trained investigators to inquire into wrongdoing, or possible wrongdoing. Typically, these investigators travel with their own security teams, and standard protocol calls for a starship captain (or starbase commander) to put the ship's (or base's) security forces at a visiting investigator's disposal. Their task is to gather facts and evidence and determine if a court martial is warranted. JAG investigations continue until the case is solved, or no clear determination can be made (at which point the file is left open until new evidence may be brought to light). Although all Starfleet captains can call for a JAG investigation of personnel under their command, most ranking officers prefer to conduct their own inquiries and submit their own subordinates for court martial. Normally, JAG investigators become involved in a case only when a member of Starfleet is accused of wrongdoing by someone outside of his chain of command. If no JAG officer is available to conduct an investigation, it falls to the highest ranking officer to appoint and investigator - normally the ship's Security Chief.
Starfleet personnel who show particular aptitude in law, or who attended law school on their homeworlds, are frequently tapped to serve in the JAG Corps for at least one tour of duty. This is not restricted to those with a legal bent, however. The JAG officer requires officers with a nose for the truth and an unswerving devotion to the principles, rules, and regulations that govern Starfleet. Security officers, science officers, or other experts in the field could find themselves detailed to the JAG Corps for a particular investigation. The Center for Advanced Training provides classes to those who desire legal training, most notably those Command personnel aiming for promotion to Starfleet's upper echelons.
Although most infractions can be handled through less severe reprimands, or short incarceration in a brig, some crimes are so severe as to warrant a court martial. A court martial is a trial under Starfleet's Uniform Code of Justice, as opposed to Federation civilian law, and is conducted by a committee of officers.
Any officer of the rank of Captain or higher can submit a subordinate officer for immediate court martial (though frivolously abusing this right is itself a court martial offense). Officers of the Judge Advocate General's office have the power to submit any member of Starfleet for court martial, as long as they first submit an approved finding to a JAG officer of the rank of Captain or higher. Once it has been called, a court martial is typically convened within seventy-two hours. As part of the formal order of court martial, the presiding representative of the JAG's office nominates both a prosecuting advocate and an advocate for defense. Typically, both advocates are officers from the local JAG office, however, the JAG representative can nominate any available Starfleet officers as ad hoc advocates. The accused always had the right to refuse the nominated defense advocate and either serve as his own lawyer or appoint an eligible officer of his choice.
A panel of three judges presides over a court martial proceeding, usually officers from the JAG office. If none are available, the JAG office typically appoints an ad hoc judge - the fleet admiral for the sector. Only officers ranked Commander or higher can serve as judges, and no officer with an obvious conflict of interest, such as friendship, is allowed to serve. If possible the JAG representative who signs the order for court martial appoints a full three-judge panel.
Procedurally, a court martial is handed very much like a civilian crime trial. Both sides make opening statements, the prosecution presents its witnesses and evidence, the defense presents its case, and both sides make closing arguments. Each side had the right to cross-examine the witness presented by the other side, and almost all the rules of evidence and courtroom procedure applicable to civilian trials apply equally to courts martial. Unlike civilian trials, however, court martial proceedings do not employ juries; guilt or innocence is determined by the panel of judges. Courts martial tend to be less formal affairs, moving along at a much faster pace than a civilian trial, and rarely take more than a week to complete.