A controller for a four-wheel drive vehicle provided with a transfer device comprising a lock mechanism that locks a center differential and a switch mechanism that switches between a two-wheel drive state and a four-wheel drive state, the transfer device distributing an output from an engine to front and rear shafts (16, 18), the controller comprising: a first operation part operated by a passenger to switch drive modes of a vehicle; a second operation part operated by the passenger to switch off-road traveling modes indicating traveling modes for off-road driving of the vehicle; a transfer controller that controls an arrangement of the transfer device by controlling the lock mechanism and the switch mechanism, in response to the drive mode selected by the first operation part, such that the vehicle enters the two-wheel drive state or the four-wheel drive state, the arrangement of the transfer device determining distribution of an output from the engine to the front and rear shafts (16, 18); and a detector that detects the arrangement of the transfer device, the controller being characterized by further comprising: a determiner that determines whether a switching of the traveling modes is permitted or not based on the drive mode selected by the first operation part and the arrangement detected by the detector; and a setter that sets one of the traveling modes based on the arrangement detected by the detector and input operations to the first operation part and the second operation part when the determiner determines the switching of the traveling modes is permitted, and maintains the current traveling mode when the determiner determines the switching of the traveling modes is not permitted. a first operation part operated by a passenger to switch drive modes of a vehicle; a second operation part operated by the passenger to switch off-road traveling modes indicating traveling modes for off-road driving of the vehicle; a transfer controller that controls an arrangement of the transfer device by controlling the lock mechanism and the switch mechanism, in response to the drive mode selected by the first operation part, such that the vehicle enters the two-wheel drive state or the four-wheel drive state, the arrangement of the transfer device determining distribution of an output from the engine to the front and rear shafts (16, 18); and a detector that detects the arrangement of the transfer device, the controller being characterized by further comprising: a determiner that determines whether a switching of the traveling modes is permitted or not based on the drive mode selected by the first operation part and the arrangement detected by the detector; and a setter that sets one of the traveling modes based on the arrangement detected by the detector and input operations to the first operation part and the second operation part when the determiner determines the switching of the traveling modes is permitted, and maintains the current traveling mode when the determiner determines the switching of the traveling modes is not permitted. a determiner that determines whether a switching of the traveling modes is permitted or not based on the drive mode selected by the first operation part and the arrangement detected by the detector; and a setter that sets one of the traveling modes based on the arrangement detected by the detector and input operations to the first operation part and the second operation part when the determiner determines the switching of the traveling modes is permitted, and maintains the current traveling mode when the determiner determines the switching of the traveling modes is not permitted.