Anecdotal:
I found the most effective way is not to explain it all at one time, but to make off the cuff remarks that clearly show you disagree with what they said without making it sound like you're attacking them because they'll stop internalizing anything you say instantly that way.
I knew someone that often made homophobic comments, and I always made a point to casually reply "nah, it never really bothered me", or "sure, but it doesn't affect your life at all" and shrug.
For a long time they said something like "yuck, It's just gross" or " I don't like it", but I never pursued the topic any more than my disagreeing comments until months later they asked me "okay, seriously how does it not bother you that gay people..."
That's the point where you can bring up logic or expand on what you think.
And again, don't go overboard, but you can expand on the points that it doesn't affect your life how other people choose to love or who other people choose to love, and isn't the world a better place with more love in it?
Simple, concise, irrefutable statements that are easy to digest once someone is asking questions and willing to listen to your answer.
Then you just let them digest that.
Apparently the comment that eventually clicked in their head in my situation was "isn't the world a better place with more love in it?" because we interacted almost daily and they didn't make homophobic comments for a while after the one time we had a longer conversation about gay people(they had been making less homophobic comments around me since I began replying with those casual comments during this whole process, which took months probably), and then one day we went to dinner again and he explicitly told me that that comment had been rattling around in his head and while he still thought it was weird for two dudes to kiss each other, he had come to the conclusion that it was crazy for him to react so strongly because obviously the world is a better place with more love in it and besides it doesn't actually affect his life at all.
And I just said " that's great" or something and left it at that.
So now anytime I hear someone say something -ist, I casually but directly disagree and then let it go until the next time or unless they ask what I mean.
Anyone I've tried to talk to in any extended manner without them expressing curiosity first pulls their limbs and head into a shell and works on developing whatever prejudice they have to make it more foolproof and less prone to examination.
2nd:
It doesn't always take months, I mett one guy walking his dog sitting at a park bench once who had similar prejudices and I did the exact same thing, a casual comment and he wanted to enter into a deeper conversation right away that it later became clear, had led him to critically examining his ideas.
But patience is key for sure with this method.