I believe it was a mixture of both. When Madara came along I think he just went completely insane. It probably also didn't help that he killed Itachi and learned that Itachi had loved him.
Tbh I never blamed him for anything although he did do some bogus shyt but how can you blame a man whose whole family/clan got slaughtered by his own idol ?
I think he made an insane choice of leaving the village and fighting against comrades especially Naruto (the closest friend, he ever had & vice versa) to do so.