A two-dimensional (2D) cellular automaton (CA)-finite difference method (FDM) model is proposed to simulate the dendrite growth and microporosity formation during solidification of aluminum alloys. The model involves a three-phase system of liquid, gas, and solid. The growth of both dendrite and gas pore is simulated using a CA approach. The diffusion of solute and hydrogen is calculated using the FDM. The model is applied to simulate the formation and interactions of dendrites and micropores in an Al-7wt.%Si alloy. The effects of initial hydrogen concentration and cooling rate on microporosity formation are investigated. It is found that the porosity nuclei with larger size grow preferentially, while the growth of the small porosity nuclei is restrained. The competitive growth between porosities and dendrites is also observed. With the increase of initial hydrogen concentration, the incubation time of porosity nucleation and growth decreases, and the percentage of porosity increases, while porosity density does not increase apparently. With the decrease of cooling rate, porosity nucleates and starts to grow at higher temperatures, and the percentage of porosity increases, but the porosity density displays a decreasing trend. In addition, at a slower cooling rate, the competitive growth between porosities and dendrites becomes more evident, leading to a more non-uniform distribution of porosity size, and an increased maximum porosity size. The simulation results agree reasonably with the experimental data in the literature.