The olive tree is an important oil woody plant with high economic value, yet it is vulnerable to the attack of numerous fungi. The successful control of olive fungal diseases requires a comprehensive understanding of the disease resistance mechanisms in plants. Here, we isolated Alternaria alternata from the diseased leaves of olive plants, and screened a resistant ("Leccino") and susceptible ("Manzanilla de Sevilla") cultivar from eight olive cultivars to explore their resistance mechanisms. Transcriptomic and metabolomic analyses identified the flavonoid biosynthesis as a key defense pathway against A. alternata. Five important transcription factors associated with flavonoid biosynthesis were also determined. The overexpression of OeWRKY40 significantly enhanced the disease resistance of the susceptible cultivar and upregulated the expression of genes involved in flavonoid biosynthesis and the accumulation of related metabolites. LUC assays further proved that OeWRKY40 can activate the expression of OeC4H. These results help to better clarify the molecular mechanisms of flavonoid biosynthesis against A. alternata. Our study provides key information for further exploration of the molecular pathways of olive plants and their resistance to fungi, an important factor for molecular breeding and utilization of resistant cultivars.