A state is not necessary to defend the revolution, even if only part of the world goes anarchist and the other does not. Simply arm the workers. Form decentralized, democratic militias, if necessary, to wage guerilla war against any imperialist invaders. The classic example of this is the Makhnovists, but there's also the anarchist militias in Spain as another example.
The main function of the state may arguably be to defend the ruling class, but even if true that does not mean all class based violence is a state. If a worker hits his boss he does not suddenly become a state. The state is characterized by centralization of power and monopoly or near-monopoly of force, not merely class based violence.
To say "State is a product of the existence of social classes" isn't really correct. The inverse is equally correct, "Social classes is a product of the existence of the state." They are two sides of the same coin. If you have a state you will have a (minority) ruling class and vice versa. Eliminating the relations of production that result in social classes does not require a state.
The state is defined by:
1) A "monopoly of violence" in a given territorial area;
2) This violence having a "professional," institutional nature;
3) A hierarchical and authoritarian nature - centralisation of power and initiative into the hands of a few.
The means of production should be directly expropriated by the workers during the revolution. We all take over our workplaces and run it directly democratically (or by consensus or some other non-hierarchical means) via worker assemblies. After that the various worker assemblies should form decentralized confederations to coordinate their activities in a decentralized fashion, with actual decision making power staying in the worker assemblies. Once this is set up it is a simple matter to abolish commidity production and implement need based production.
The whole point of an anarchist revolution is to abolish classes. The moment the means of production are expropriated by the working class the bourgeoisie ceases to exist. There is no ruling class.
Former capitalists may exist, but an actual capitalist class would not longer exist. There would no longer be a class system.
In Marxist usage "centralism," like "state," has a shifting two-sided meaning. On the one hand there is its usual meaning: subordination to a central authority (or "one deciding will" as Engels put it). On the other hand it is sometimes used in an overly broad manner that confuses centralization with coordination. Lenin does this in state & revolution. It is entirely possible to coordinate actions without centralism. The typical Marxist approach to defending oneself from decentralist criticisms, employed by Lenin & others, is to defend centralism in the overly broad sense (equating it with coordination) and then erroneously equating that with support for centralisation in it's ordinary sense (subordination to a central authority).