We propose a model of fermion masses and mixings based on SU(5) grand unified theory (GUT) and a D4 flavor symmetry. This is a highly predictive 4D SU(5) GUT with a flavor symmetry that does not contain a triplet irreducible representation. The Yukawa matrices of quarks and charged leptons are obtained after integrating out heavy messenger fields from renormalizable superpotentials while neutrino masses are originated from the type I seesaw mechanism. The group theoretical factors from 24- and 45-dimensional Higgs fields lead to ratios between the Yukawa couplings in agreement with data, while the dangerous proton decay operators are highly suppressed. By performing a numerical fit, we find that the model captures accurately the mixing angles, the Yukawa couplings and the CP phase of the quark sector at the GUT scale. The neutrino masses are generated at the leading order with the prediction of trimaximal mixing while an additional effective operator is required to account for the baryon asymmetry of the universe (BAU). The model is remarkably predictive because only the normal neutrino mass ordering and the lower octant of the atmospheric angle are allowed while the CP conserving values of the Dirac neutrino phase δCP are excluded. Moreover, the predicted values of the effective Majorana mass mββ can be tested at future neutrinoless double beta decay experiments. An analytical and a numerical study of the BAU via the leptogenesis mechanism is performed. We focused on the regions of parameter space where leptogenesis from the lightest right-handed neutrino is successfully realized. Strong correlations between the parameters of the neutrino sector and the observed BAU are obtained.