Specifically, it's a contact metamorphic rock. This means it forms when existing rocks (the "protolith") are transformed by the heat and/or chemically active fluids from an igneous intrusion (like a volcano or magma chamber).
Here's the breakdown:
* Metamorphic: The rock's original structure and mineral composition have been altered by heat and/or pressure.
* Contact: The transformation is caused by direct contact with a heat source, usually magma or lava.
The original rock (protolith) can be almost anything: shale, limestone, sandstone, even other metamorphic rocks. The resulting hornfels will have a distinctive hard, fine-grained texture, often with a "horny" appearance, hence the name.