Aphids are a familiar sight in the garden, sucking the juices out of your rose bushes. Luckily, so are ladybugs, which prey on aphids and keep them in check.

But the relationship between predator and prey is more complex than you might think. Aphids may be important to the survival of some ladybug species we have come to know and love by warding off another predator that has been moving in and feasting on them.

The arrival about 30 years ago in the United States of the multicolored Asian lady beetle, or Harmonia axyridis, which gleefully devours other ladybugs’ larvae, led to a drop in numbers of the seven-spotted lady beetle. Although the seven-spotted beetle is also an invasive species, it has been around longer than the Asian lady beetle, and exists alongside native ladybug species, which also take a beating.

However, some aphids contain a substance that’s much more toxic to this aggressive invader than to the other ladybugs. As a result, researchers show in a paper in the Proceedings of the Royal Society B, these aphids may provide refuge to the other ladybug species by killing off their common enemy.