The short answer is that anarchism was a product of the proletarian struggle just as much as Marxism was (although I think the reality is a bit more complicated than that in the case of either movement).
But I'm afraid this is historically wrong. Anarchist thought might not have existed in feudal Japan, but anarchistic thought and actions did exist in Ancient Greece (Stoics), in Ancient Rome (Spartacus) in Ancient Persia (Mazdak) and even Ottoman Empire (Shiekh Bedreddin). It is, in my opinion, more of an emotional thing than being a scientific thing. Please don't misunderstand me, I'm not trying discredit anarchism at all, but I am saying that it is more of a product of a emotional rejection of the current ruling class, whereas Marxism is specifically a product and the highest theoretical expression of the proletarian struggle.
The short answer is that anarchism was a product of the proletarian struggle just as much as Marxism was (although I think the reality is a bit more complicated than that in the case of either movement).