The most popular candidate with the party members was Kemi Badenoch, a black woman, so it doesn’t seem credible that people voted against Rishi Sunak mostly because of race.
Well, supposedly the most popular was a black woman, the most competent was an Asian man, and who gets the post in the end? The most incompetent of them all, whose only advantage is being white.
The members weren’t allowed to choose Badenoch, she was eliminated at an early stage by the MP vote, probably because she was too radical and lacked ministerial experience.
Rishi Sunak was claiming to be resident in the US while Chancellor of the Exchequer, while his wife was claiming non dom status to avoid paying tax. He was also hated by the supporters of the previous PM because he wielded the knife.
It’s not a shock that elections are not won on competence.
Different selectorates, different priorities. MPs who voted for the final two to be on the ballot had more established personal and political relationships with other candidates and saw her as an inexperienced MP with a few strange ideas about organising the Cabinet who was obsessed with culture war bullshit. The Conservative Party membership that didn't get to see her on the ballot were impressed with her debate performances and loved the culture war bullshit.
(tbh I didn't see much indication she was the 'most popular', but there were definitely plenty of members of the party receptive to her message, doubtless including many of those most likely to espouse racist sentiments)
I reckon racism would have played a part with some of the Tory party members. However, I think Sunak’s bigger problem was that he came across as very, very swish, fake, metropolitan and brown nosey which the traditional Tory party membership (country folk) absolutely detest. The City job, the expensive suits and short trousers with loafers, the pretending to drive a car, the “my favourite tv program is Emily in Paris”, the “I’m a Coca Cola addict”, the “Thanks PM” meme. He was Team Brexit, but everything about his personality screamed Team Remain. Contrast this with Liz Truss who was Team Remain but who “welcomes any Britain to go join Ukraine and fight Putin”, bellows for tax cuts for the rich and generally presents herself as a very traditional almost rural conservative person. I think when you look at it through this lens it makes a lot more sense.
If that is not racism, I don't know what it is.