Stress is the reason why we find it hard to empathise with someone we do not know, researchers suggest.
In separate tests in mice and people, empathy towards strangers increased when stress hormones were blocked by a drug.
Playing a fun video game with a stranger was found to have a similar effect to the drug.
The Canadian and American research team published their findings in Current Biology.
Previous studies have shown that the ability to feel or share someone else's pain is not something unique to humans. Mice can feel empathy too.
But in both species, empathy is stronger between those that recognise each other and all but absent between those unfamiliar with each other.
Stress levels have also been shown to rise in both mice and people in the presence of strangers.
Of mice and men
In this study, researchers treated mice with a stress-blocking drug and watched their response when confronted with other mice in pain.
They found that the mice became more empathetic and more compassionate to strangers, reacting in a way they would normally react to familiar mice.
When the mice were put under stress, they showed less empathy towards other mice in pain.
Tests in undergraduate students using the same drug showed exactly the same effect, the study said.
They were asked to rate the pain of a friend or stranger whose hand was plunged into ice cold water for 30 seconds.
Students who took the drug reported feeling the pain of a stranger more deeply than those who did not take it.
They also showed more pained facial expressions and touched their own hands more when watching someone else in pain.
Dr Jeffrey Mogil, study author and neuroscientist from McGill University in Montreal, Canada, said his team's findings suggest that the stress system in the brain can have a "veto" on our empathy system.
"Yet few people would realise that there is a stress response when you're in a room with a person you don't know," he added.
However, he discovered that the key to reducing stress levels quickly was to play a simple ice-breaking game.
In the study, some students who did not know each other played a fun video game which required them to work together to play well-known songs.
"By the time it came to the test, there was no longer any stress," Dr Mogil said.
He also said it was intriguing that the impact of stress on empathy appeared to be identical in mice and humans.
"This suggests either that mice are more complicated than we think or that the principle underlying human social interactions is simpler than we think.
"When it comes to social behaviour, mice are people too."