Extended wakefulness, or sleep deprivation, impairs cognitive performance and brain glucose metabolism. A ketogenic diet (KD) provides an alternative fuel source, ketone bodies, that could elicit a metabolic benefit during sleep deprivation. A randomised, cross‐over trial was conducted with seven male military personnel. Participants ingested an iso‐energetic ketogenic diet or carbohydrate‐based diet for 14 days, immediately followed by 36 h of extended wakefulness and separated by a 12 day washout. Cognitive performance, mood, subjective sleepiness, capillary blood glucose, and D‐β‐hydroxybutyrate concentrations were measured every 2 h during extended wakefulness. Linear mixed models were used to analyse data. D‐β‐hydroxybutyrate was higher (p < 0.001) and glucose was lower (p < 0.01) on the KD compared with the carbohydrate‐based diet. The KD improved psychomotor vigilance task performance (number of lapses, mean reciprocal response time, mean fastest 10% response time (RT), and mean slowest 10% RT; all p < 0.05), running memory continuous performance test performance (RT and number of correct responses per minute; both p < 0.01), and vigour, fatigue, and sleepiness (all, p ≤ 0.001) compared with the carbohydrate‐based diet. In conclusion, a KD demonstrated beneficial effects on cognitive performance, mood, and sleepiness during 36 h of extended wakefulness compared with a carbohydrate‐based diet.