In the United States, a public defender is a lawyer whose duty is to provide legal counsel and representation to indigent criminal defendants who are unable to pay for legal assistance. Public defenders are employed by the government (at the federal and county level), as opposed to criminal defense attorneys in private practice.
Not all jurisdictions have public defender offices. In certain areas, indigent defendants are represented by private attorneys that are appointed by the court, or by legal aid attorneys whose offices have contracts with the court.
In the U.S., some federal, state, and county public defenders are organized into private corporations that receive public funding but are not directly supervised by the executive branch. Some federal, state, and county public defenders, in contrast, are technically part of the executive branch. Still others are considered to be part of the judiciary.
Complex conflict of interest problems often arise where multiple defendants participated in a single crime (like a bank robbery or a drive-by shooting). Some defendants may be in a situation where it is in their best interest to turn on their co-defendants and testify for the state as a witness in exchange for a reduced sentence. To ensure that each defendant is afforded his constitutional right to a zealous and loyal defense, a handful of American jurisdictions have created an office of the "alternate public defender" to handle such complex cases.
In civil law countries, following the model from the Napoleonic Code of Criminal Procedure, the courts typically appoint private attorneys at the expense of the state. Defense attorneys are not directly employed by the government, which, as noted above, would perhaps put them into too close a relationship with the interests of the government.