Agates are created in igneous rock when it is subject to certain conditions. Igneous rock itself is formed by volcanic reaction, when molten rock is forced up through holes and cracks in the earth to form mountains, islands and other natural formations. This violent process creates spaces and bubbles in the rock as it cools, in the same way pumice and other volcanic minerals are formed. Some of these bubbles are solitary, while others are interconnected, and many are open to outside elements through cracks and holes in the rock.
When this kind of volcanic rock forms near water, the water is often forced into these pockets and bubbles. Since this water has been stirred up it is usually rife with other types of minerals, such as silica. When silica-rich water becomes trapped in these volcanic rock bubbles, it eventually forms an acidic type of gel, which begins to eat away at the surrounding igneous rock. The gel dissolves surrounding iron and other metals and leaves a layer of residue that settles into the gel. This layer is followed by other layers, until over time the gel loses water and the entire substance begins to crystallize.