– Xochielt Sanchez
Answer by Tim Dees:
The other answers here are mostly correct, but there are some flaws in each.
Police are usually general-purpose law enforcement officers. They are most often employed by a city government, but may be employed by a county, state, college, hospital, transit district, or other quasi-governmental organization with the power to create a law enforcement branch.
The "usually" part has to do mainly with federal police forces. If you pay close attention when you're in Washington, D.C. and its environs, you'll notice that almost every federal government agency has its own police. There's the Bureau of Printing and Engraving Police, the FBI Police, the Smithsonian Institution Police, the U.S. Capitol Police, the U.S. Supreme Court Police, and so on. They are armed, they have police-type uniforms, they often have marked patrol cars with emergency lights and sirens, and they can make arrests and serve warrants. However, their function is more like a security force, protecting the people and facilities under the umbrella of their employer. Serious crimes committed on or in their facilities will usually be handled by an inspector general's office (that also has police powers, and special agents, like the FBI does) or the FBI. The cars are mostly driven around the perimeter streets and possibly between satellite facilities.
The sheriff is an elected official, the chief executive of a sheriff's department. Most sheriffs operate under the county government, with a few city sheriffs (mostly in Virginia, where cities are legally not a part of the county that surrounds them). 49 states have sheriffs. The only exception is Alaska, which has no counties.
The word "sheriff" is a portmanteau of "shire reeve," which was the tax collector in medieval England. In some states, the sheriff is also the tax collector.
In most states, the sheriff is a constitutional officer, meaning that counties must have a sheriff. The office may be largely ceremonial, with some duties to serve papers and provide security for the courts. In other states, the sheriff does these things and also runs the county jail. In most states, the sheriff does all of these, and also provides general law enforcement services to unincorporated areas of the county and some cities that do not have their own police, and contract to the sheriff to provide police services.
A few counties have both a sheriff's department (also called a sheriff's office–the names are more or less interchangeable) and a county police department. This usually comes about when the county government doesn't want to have a chief law enforcement officer they can't fire at will. The county police department has a chief of police, who reports to the county commission and serves at their pleasure. Where this happens, the county sheriff is relegated to running the jail and serving legal process.
Line employees of a sheriff's department are called deputies or deputy sheriffs. They generally have the same law enforcement powers as a police officer.
Rangers, at least as general-service law enforcement officers at the state level, are limited to Texas. The Texas Rangers have a history going back many years, and are the top of the police pecking order in Texas. Many states will have park or forest rangers who work for their proprietary government subdivisions (division of state parks, department of forestry, etc.), and may or may not have police powers (they usually do). Where they do not have police powers, they generally function as naturalists or conservation officers.
Most state-level law enforcement officers are members of state highway patrols or state police agencies, and have the title of "trooper." California is an exception. California Highway Patrol officers have the title State Traffic Officer.
A marshal is an enforcement officer of the court. Marshals may provide security for the court and court staff, and may also serve subpoenas and arrest warrants. At the federal level, the U.S. Marshals (not marshalls) Service provides security for the courts, transports witnesses and prisoners to and from court, may transport inmates between federal corrections facilities, and runs the witness protection program.
A city marshal might serve subpoenas, provide court security, and take custody of people arrested on warrants. In Reno and Las Vegas, for example, when a city police officer (the Las Vegas Metropolitan Police Department is an amalgam of the former Las Vegas Police and Clark County Sheriffs Office, formed in 1973, and headed by an elected sheriff) locates someone with an arrest warrant issued by the municipal court, they can call a deputy marshal to the scene. The deputy marshals wear police-type uniforms and drive marked patrol cars. They take custody of the arrestee and book them at the county jail. The police officer can then resume patrol.