Oily wastewater caused by marine oil spills brings great harm to the environment. In this work, the application of gas flotation with microbubbles and nanobubbles in separating crude oil droplets from oily wastewater is reported. The experiments were conducted in a flotation column with an internal diameter of 5.2 cm and a height of 100 cm. Response surface methodology was employed to examine the effects of three experimental factors (initial oil concentration, flotation time, and temperature of inlet wastewater) on the oil separation performance and the interaction between experimental factors. A good agreement was obtained between the predicted and experimental data of oil separation efficiency, with a high R2 of 0.99 and an adjusted R2 of 0.98. The optimization results demonstrate that the maximum oil separation efficiency (98.3%) was achieved under optimum experimental conditions of 524.5 mg/L initial oil concentration, 28.6 min flotation time, and 21.2°C inlet wastewater temperature.