Contact metamorphism occurs when magma is injected into the surrounding solid rock (country rock). The changes that occur are greatest where the magma comes into contact with the rock. The temperatures were highest there and decreased with distance from it.