Image Source
In a volcanic eruption, the rocks and ashes that come off in the cloud that expels the volcano are, in theory, electrically neutral. However, they come out so hot from within the Earth that not every particle is neutral: many are charged positively or negatively, and several are charged along the way as they collide with each other and static occurs.
Now, for rays to appear, it is necessary that these particles separate and that the positive ones go to one side, and the negative ones to another. This occurs more or less naturally, since as they move, an electromagnetic field is created. When the charge difference becomes very large, the electrons flow and the rays are produced.
Image Source
Anyway, as with the rest of the rays, the exact mechanisms that produce the separation of the charges are still debated by the scientists, so the explanation is still not 100% clear. What is clear is that volcanic eruptions can produce lightning.
Image Source
Note: @sirknight started a contest and its daily theme's are:
Sunday-Light
Monday-Darkness
Tuesday-AnimalKingdom
Wednesday-Structures
Thursday-ForcesinNature
Friday-LoveBeautyFreedom
Saturday-Agriculture