Kaposi sarcoma is caused by infection with human herpesvirus 8 (HHV-8), also known as Kaposi sarcoma-associated herpesvirus (KSHV). However, not everyone infected with HHV-8 develops Kaposi sarcoma, as other factors such as a weakened immune system also play a role.