Those that responded to therapy tended to have a richer, more diverse microbiome than those that did not.
And they had different bacteria too. High levels of Faecalibacterium and Clostridiales appeared to be beneficial, while Bacteroidales species were bad news in the study.
Tissues samples showed there were more cancer-killing immune cells in the tumour of people with the beneficial bacteria.
The team then performed a trans-poo-sion, a transplant of faecal matter, from people to mice with melanoma.
Mice given bacteria from patients with the “good” mix of bacteria had slower-growing tumours than mice given “bad” bacteria.
Dr Jennifer Wargo, from Texas, told the BBC: “If you disrupt a patient’s microbiome you may impair their ability to respond to cancer treatment.”
She is planning clinical trials aimed at altering the microbiome in tandem with cancer treatment.
She said: “Our hypothesis is if we change to a more favourable microbiome, you just may be able to make patients respond better.
“The microbiome is game-changing, not just cancer but for overall health, it’s definitely going to be a major player.”
Mark Fielder, president of the Society for Applied Microbiology and professor of medical biology at Kingston University, said the study showed the importance of understanding the micro-organisms that call our bodies home.
He told the BBC: “It’s really interesting and holds a lot of promise, we need to do more work but there are exciting glimmers here in treating some difficult diseases.
“Some claim the microbiome is the answer to everything, I don’t think that’s the case.
“But once we understand more, it could be that microbiome manipulation is important in changing people’s health.”
Dr Emma Smith from Cancer Research UK, said: “It’s fascinating.
“One of the big challenges for using immunotherapies to treat cancer is understanding which patients will respond, and this research is a step towards helping doctors to identify these people.”