Judges are usually elected by voters, appointed by the president, or selected by a state’s governor or legislature.
Some US states use partisan elections to choose judges, where candidates are nominated by political parties. These candidates are selected through partisan primaries.
In other states, judges run in nonpartisan elections. The judicial candidates do not reveal any party affiliation in the campaign. Parties might endorse candidates, but the candidate does not run with an association with a party.
Governor, county or state legislature-appointed judges are usually selected from those who have previously been elected as judges in their state or district. Depending on the state, they may serve for a term that is set out in their state constitution and then must be re-elected by voters if they wish to continue serving on the bench.
Presidential appointments are usually made when a judge retires or dies. The president also has the power to appoint judges to fill vacant positions. However, these appointments are not permanent and can be terminated at any time.
Judicial election methods by state – Ballotpedia