The dynamics of mechanically interlocked molecules such as catenanes and rotaxanes have been studied in solution as examples of rudimentary molecular switches and machines. A metal–organic framework with a [2]rotaxane as a building block demonstrates that such dynamic processes can also operate inside a solid-state material.