Bilirubin in plasma is mostly produced by the destruction of erythrocytes. Heme is metabolized into biliverdin (via heme oxygenase) and then into bilirubin (via biliverdin reductase) inside the macrophages. 
Bilirubin is then released into the plasma and transported to the liver bound by albumin, since it is insoluble in water in this state. In this state, bilirubin is called unconjugated (despite being bound by albumin). 
In the liver, unconjugated bilirubin is up-taken by the hepatocytes and subsequently conjugated with glucuronic acid (via the enzyme uridine diphosphate–glucuronyl transferase). In this state, bilirubin is soluble in water and it is called conjugated bilirubin. 
Conjugated bilirubin is excreted into the bile ducts and enters the duodenum. During its transport to the colon, it is converted into urobilinogen by the bacterial enzyme bilirubin reductase. Most of the urobilinogen is further reduced into stercobilinogen and is excreted through feces (air oxidizes stercobilinogen to stercobilin, which gives feces their characteristic brown color). 
A lesser amount of urobilinogen is re-absorbed into portal circulation and transferred to the liver. For the most part, this urobilinogen is recycled to conjugated bilirubin and this process closes the enterohepatic circle. There is also an amount of urobilinogen which is not recycled, but rather enters the systemic circulation and subsequently the kidneys, where it is excreted. Air oxidizes urobilinogen into urobilin, which gives urine its characteristic color.
In parallel, a small amount of conjugated billirubin can also enter the systemic circulation and get excreted through urine. This is exaggerated in various pathological situations.