The identification of factors affecting the first flush phenomenon is important for the control of urban nonpoint source pollution. This study developed machine learning algorithms, the regression tree (RT) and random forest (RF) algorithms, to predict the mass first flush ratio (MFFn) from seven rainfall-related variables. We also evaluated the prediction performance of the two algorithms and the relative importance of the seven variables in model prediction. The RF algorithm outperformed the RT algorithm in terms of Akaike information criterion (AIC) values. In general, the target variables simulated using the RF algorithm had lower AIC values than did those of the RT algorithm, except for T-N and T-P. The RF algorithm also provided acceptable performance statistics for the MFF10 to MFF20 of biochemical oxygen demand (BOD) (R2 = 0.71 and 0.67; Nash-Sutcliffe efficiency (NSE) = 0.67 and 0.52), chemical oxygen demand (COD) (R2 = 0.70 and 0.71; NSE = 0.66 and 0.62), total organic carbon (TOC) (R2 = 0.70 and 0.63; NSE = 0.56 and 0.57), and total phosphorus (T-P) (R2 = 0.72 and 0.71; NSE = 0.68 and 0.58). Suspended solids (SS) predicted by the RF algorithm showed an acceptable value for R2 (0.68 and 0.64) but a low NSE for the MFF20 (NSE = 0.48). However, the prediction of MFF30 was unacceptable for all target variables. The rainfall-related variables showed different relative importance estimates among the water quality parameters in the MFFn prediction. Results also showed that BOD and COD were closely associated with rainfall intensity (RI). TOC and T-P showed strong relationships with RI and antecedent rainfall (AR). SS was closely related to RI and rainfall duration (Rdur). T-N showed strong relationships with Rdur, respectively. This study demonstrated that the RF algorithm could be a useful tool to predict the MFF10 and MFF20 of BOD, COD, TOC, and T-P on the basis of rainfall characteristics in urban catchments.