In the aerated mud underbalanced drilling, the bottomhole pressure is intentionally reduced by reducing the hydrostatic mud column due to the two-phase flow occurrence in the annulus. However, in the field, it is incorrectly assumed that the aerated mud can be treated as a homogenous mixture of liquid and gas, neglecting the slippage between the two phases and, thus, the flow pattern and its effect on pressure drop calculation. Accurate prediction of bottomhole pressures and optimal flow rates requires the modeling of the complex flow mechanisms involved in aerated mud flow, which includes flow pattern prediction and slip liquid hold-up. The objective of this study is to develop a simulation tool to optimize the gas and liquid volumetric flow rates using bottomhole pressure and borehole stability as the selecting criterion. The investigation of the drill pipe size effect on the optimal gas and liquid flow rates was also part of this study. A vertical, two-phase, flow comprehensive mechanistic model is modified and incorporated in the simulator to predict the pressure drop in the annulus according to the existing flow pattern. The modified model predicts the annulus bottomhole pressure and the corresponding optimal gas and liquid flow rates for various drill pipe diameters. The simulator was validated using field data, and the results show a fairly accurate match. In conclusion, the optimization of required flow rates for aerated mud drilling was achieved by the developed simulator, which considers flow pattern occurrence in the pressure drop calculation. Furthermore, the drill pipe size was found to be an influential parameter for flow rate optimization.