Actually completely unrelated, but since this quote is really famous by itself without context here’s the full paragraph, formatted for convenience. Every meme quotation is an opportunity to read theory.
Communists do not fight for personal military power (they must in no circumstances do that, and let no one ever again follow the example of Chang Kuo-tao), but they must fight for military power for the Party, for military power for the people.
As a national war of resistance is going on, we must also fight for military power for the nation. Where there is naivety on the question of military power, nothing whatsoever can be achieved. It is very difficult for the labouring people, who have been deceived and intimidated by the reactionary ruling classes for thousands of years, to awaken to the importance of having guns in their own hands.
Now that Japanese imperialist oppression and the nation-wide resistance to it have pushed our labouring people into the arena of war, Communists should prove themselves the most politically conscious leaders in this war. Every Communist must grasp the truth, “Political power grows out of the barrel of a gun.”
Our principle is that the Party commands the gun, and the gun must never be allowed to command the Party. Yet, having guns, we can create Party organizations, as witness the powerful Party organizations which the Eighth Route Army has created in northern China. We can also create cadres, create schools, create culture, create mass movements. Everything in Yenan has been created by having guns. All things grow out of the barrel of a gun.
According to the Marxist theory of the state, the army is the chief component of state power. Whoever wants to seize and retain state power must have a strong army. Some people ridicule us as advocates of the “omnipotence of war”. Yes, we are advocates of the omnipotence of revolutionary war; that is good, not bad, it is Marxist. The guns of the Russian Communist Party created socialism. We shall create a democratic republic.
Experience in the class struggle in the era of imperialism teaches us that it is only by the power of the gun that the working class and the labouring masses can defeat the armed bourgeoisie and landlords; in this sense we may say that only with guns can the whole world be transformed. We are advocates of the abolition of war, we do not want war; but war can only be abolished through war, and in order to get rid of the gun it is necessary to take up the gun.
Source is “Problems of War and Strategy”, section II “The War and History of the Kuomintang”.
I wish this quote more frequently included the additional context when it is used, mostly for the sake of those who have never read Mao and those who are not familiar with Marxism.