The exact meaning of magistrate varies widely depending upon the context. For example:
in the U.S. federal court: assists district court judges by handling minor offenses or administrative tasks such as preliminary hearings (often referred to as a magistrate judge rather than just a magistrate)
in some U.S. states: a judge in the state court
in France, Belgium, Italy, the Netherlands, and other civil law countries: a sitting magistrate is a judge and a standing magistrate is a prosecutor
in England: may be a volunteer without formal legal training who performs a judicial role with regard to minor matters
in ancient Rome: a powerful officer with both judicial and executive power
In the sixth Christian century lived Procopius, a Christian magistrate of Constantinople, in the days when Justinian was Emperor and Belisarius general.
Chapters 43-45 -- Hark!; The Chart; The Affidavit (93% in)
There are no more uses of "magistrate" in Moby Dick.