The history of policing on the railroads can be traced back to about 1860 when over 30,000 miles of railway spanned the United States. There was little organized law enforcement, and even less was available to protect the passengers and freight carried across the country using this new mode of transportation. The United States Marshals, which agency had primary jurisdiction in many cases, were few and far between in the wilderness.
Railroad companies were left in large part to protect themselves from robbery, sabotage and theft. Contract railroad police gradually appeared, usually bearing the title of special agent or detective. Two of the most famous of these new detectives were Bat Masterson and Allen Pinkerton.
Over the years many famous gangs of outlaws, as well as many lesser-known criminals, preyed upon the railroads. The James and Younger gangs, the Daltons, the Hole in the Wall gang and the Wild Bunch are among the best known.