There are three main places where volcanoes originate:
- Hot spots,
- Divergent plate boundaries (such as rifts and mid-ocean ridges), and
- Convergent plate boundaries (subduction zones)
The origin of the magma for hot spots is not well known. We do know that the magma comes from partial melting within the upper mantle, probably from depths not too much greater than 100 km. The actual source of the heat that causes the partial melting (the actual hotspot itself) is almost certainly much deeper than that, but we really don't know how deep or even exactly what a hotspot is!
At a divergent margin, two tectonic plates are moving apart, and magma that is generated in the upper mantle flows upward to fill in the space. This magma is probably generated at depths that are shallower than those for hotspot magmas. People argue about whether the magma forcing its way to the surface causes the plates to move apart or whether the plates move apart and the magma just reacts to that and fills in the space. Perhaps it is a combination of these two. The most extensive example of this type of volcanism is the system of mid-ocean ridges. Continental examples include the East African Rift, the West Antarctic Rift, and the Basin and Range Province in the southwestern US.
The final major place where volcanism originates is at convergent margins (subduction zones)--where an oceanic plate dives under either another oceanic plate or perhaps a continental plate. As the plate gets pushed further and further it starts to give off its volatiles (mostly water), and these migrate upwards into the mantle just under the overriding plate. The addition of these volatiles to this overriding mantle probably lowers the melting point of that mantle so that magma is generated. Part of the magma may also be generated by the downgoing plate actually starting to melt as it gets into the hotter and hotter interior.