We aimed to analyze the effect of a head‐to‐head virtual race on 20‐km time trial performance in well‐trained mentally fatigued cyclists. A total of 24 male professional cyclists participated in the present study, which was conducted in a within‐factors design [four experimental conditions × four times (throughout 20‐km time trial cycling)]. An avatar representing the participant on the racecourse was visible during the time trials. Then, a second virtual avatar representing the opponent was projected onto the screen in the mental fatigue head‐to‐head and control head‐to‐head experimental conditions. Measurements [rating of perceived exertion, heart rate, and eye‐tracking measures (i.e., pupil diameter)] were performed every 5‐km throughout the 20‐km time trial. As a result, impaired total time, power output, and cadence throughout the 20‐km cycling time trial were found for mental fatigue compared to mental fatigue head‐to‐head, control head‐to‐head, and control conditions (p < 0.05). Also, impaired 20‐km time trial performance (total time, power output, and cadence) was found for mental fatigue head‐to‐head compared to control head‐to‐head (p < 0.05). Moreover, lower RPE was found for the control and control head‐to‐head conditions than mental fatigue head‐to‐head and mental fatigue experimental conditions (p < 0.05). Higher pupil diameter was also found for mental fatigue head‐to‐head, control head‐to‐head, and control than the mental fatigue experimental condition (p < 0.05). In summary, the overall performance throughout the 20‐km cycling time trial was improved by the presence of a virtual opponent for the mentally fatigued cyclists.