Recent work has shown that muddy sediments are elastic solids through which animals extend burrows by fracture, whereas non-cohesive granular sands fluidize around some burrowers. These different mechanical responses are reflected in the morphologies and behaviours of their respective inhabitants. However, Armandia brevis, a mud-burrowing opheliid polychaete, lacks an expansible anterior consistent with fracturing mud, and instead uses undulatory movements similar to those of sandfish lizards that fluidize desert sands. Here, we show that A. brevis neither fractures nor fluidizes sediments, but instead uses a third mechanism, plastically rearranging sediment grains to create a burrow. The curvature of the undulating body fits meander geometry used to describe rivers, and changes in curvature driven by muscle contraction are similar for swimming and burrowing worms, indicating that the same gait is used in both sediments and water. Large calculated friction forces for undulatory burrowers suggest that sediment mechanics affect undulatory and peristaltic burrowers differently; undulatory burrowing may be more effective for small worms that live in sediments not compacted or cohesive enough to extend burrows by fracture.