The functions of sleep and what controls it remain unanswered biological questions. According to the two-process model, a circadian process and a homeostatic process interact to regulate sleep. While progress has been made in understanding the molecular and cellular functions of the circadian process, the mechanisms of the homeostatic process remain undiscovered. We use the recently established sleep model system organism Drosophila melanogaster to examine dynamic changes in gene expression during sleep and during prolonged wakefulness in the brain. Our experimental design controls for circadian processes by killing animals at three matched time points from the beginning of the consolidated rest period [Zeitgeber time (ZT) 14)] under two conditions, sleep deprived and spontaneously sleeping. Using ANOVA at a false discovery rate of 5%, we have identified 252 genes that were differentially expressed between sleep-deprived and control groups in the Drosophila brain. Using linear trends analysis, we have separated the significant differentially expressed genes into nine temporal expression patterns relative to a common anchor point (ZT 14). The most common expression pattern is a decrease during extended wakefulness but no change during spontaneous sleep (n = 114). Genes in this category were involved in protein production (n = 47), calcium homeostasis, and membrane excitability (n = 5). Multiple mechanisms, therefore, act to limit wakefulness. In addition, by studying the effects of the mechanical stimulus used in our deprivation studies during the period when the animals are predominantly active, we provide evidence for a previously unappreciated role for the Drosophila immune system in the brain response to stress.