Article III of the United States Constitution establishes the federal courts as part of the federal government.
The Constitution provides that federal judges, including judges of the Supreme Court of the United States, are appointed by the President “by and with the advice and consent of the Senate.” Once appointed, federal judges:
…both of the supreme and inferior Courts, shall hold their Offices during good Behavior, and shall, at stated Times, receive for their Services a Compensation which shall not be diminished during their Continuance in Office.
Federal judges vacate office only upon death, resignation, or impeachment and removal from office by Congress; only 13 federal judges have ever been impeached. The phrase “during good behavior” predates the Declaration of Independence. John Adams equated it with quamdiu se bene gesserint in a letter to the Boston Gazette published on 11 January 1773, a phrase that first appeared in section 3 of the Act of Settlement 1701 in England.
The President is free to appoint any person to the federal bench, yet typically he consults with the American Bar Association, whose Standing Committee on the Federal Judiciary rates each nominee “Well Qualified,” “Qualified” or “Not Qualified.”
State courts deal with independence of the judiciary in many ways, and several forms of judicial selection are used for both trial courts and appellate courts (including state supreme courts), varying between states and sometimes within states. In some states, judges are elected (sometime on a partisan ballot, other times on a nonpartisan one), while in others they are appointed by the governor or state legislature.
The 2000 case of Bush v. Gore, in which a majority of the Supreme Court, including some appointees of President George H. W. Bush, overruled challenges to the election of the George W. Bush then pending in the Florida Supreme Court, whose members had all been appointed by Democratic governors, is seen by many as reinforcing the need for judicial independence, both with regard to the Florida Supreme Court and the US Supreme Court. This case has increased focus and attention on judicial outcomes as opposed to the traditional focus on judicial qualifications.
Image By Jonathunder (Own work) [GFDL (http://www.gnu.org/copyleft/fdl.html) or CC BY-SA 4.0-3.0-2.5-2.0-1.0 (https://creativecommons.org/licenses/by-sa/4.0-3.0-2.5-2.0-1.0)], via Wikimedia Commons