This holding mechanism (3) for an X-ray imaging apparatus includes a switching means (36) that switches between a state of permitting movement of a moving body (4) including an X-ray tube (1) or an X-ray detector (2) and a state of prohibiting the movement, a force direction detection means (38) that detects a direction of a force applied to a moving mechanism (31), and a permission direction determination means (7) that determines a direction in which the movement is permitted by the switching means among a plurality of directions based on a detected direction of the force.