An image forming apparatus including an image carrying member, a transfer member, support rollers, a detecting mechanism, and a controller. The image carrying member forms a toner image on its surface facing a surface of the transfer member, supported by the support rollers, which transfers the toner image to a recording medium. The detecting mechanism includes a detection roller, a roller shaft, a moving member, and a sensor, and detects a speed of the transfer member. The detection roller includes one support roller selected from the support rollers, and is provided with the roller shaft. The moving member is directly fixed to the roller shaft and rotates with the detection roller. The sensor detects a moving speed of the detection roller with the moving member. The controller controls a traveling speed of the transfer member to a target speed based on a detection result of the sensor.