Cancer can lead to cholangitis primarily through the obstruction of bile ducts. Tumors, particularly those associated with cholangiocarcinoma (bile duct cancer) or pancreatic cancer, can block the normal flow of bile. This blockage creates a conducive environment for bacterial growth, leading to infection and inflammation.