Hi Cordula, and welcome!
The story you’re looking for is from the Visuddhimagga, in Chapter IX on the divine abidings, in the section on The Breaking Down of the Barriers:
When his resentment towards that hostile person has been thus allayed, then he can turn his mind with loving-kindness towards that person too, just as towards the one who is dear, the very dear friend, and the neutral person. Then he should break down the barriers by practicing loving-kindness over and over again, accomplishing mental impartiality towards the four persons, that is to say, himself, the dear person, the neutral person and the hostile person.
The characteristic of it is this. Suppose this person is sitting in a place with a dear, a neutral, and a hostile person, himself being the fourth; then bandits come to him and say, “Venerable sir, give us a bhikkhu,” and on being asked why, they answer, “So that we may kill him and use the blood of his throat as an offering;” then if that bhikkhu thinks, “Let them take this one, or this one,” he has not broken down the barriers. And also if he thinks, “Let them take me but not these three,” he has not broken down the barriers either. Why? Because he seeks the harm of him whom he wishes to be taken and seeks the welfare of the other only. But it is when he does not see a single one among the four people to be given to the bandits and he directs his mind impartially towards himself and towards those three people that he has broken down the barriers. Hence the Ancients said:
When he discriminates between
The four, that is himself, the dear,
The neutral, and the hostile one,
Then “skilled” is not the name he gets,
Nor “having amity at will,”
But only “kindly towards beings.”
Now, when a bhikkhu’s barriers
Have all the four been broken down,
He treats with equal amity
The whole world with its deities;
Far more distinguished than the first
Is he who knows no barriers.