A simple and green hydrophobic magnetic ionic-liquid assisted dispersive liquid-liquid microextraction (MIL-DLLME) was optimized for the determination of trace cadmium (Cd (II)) in environmental and food samples by flame atomic absorption spectrophotometer. To achieve selective and sensitive extraction of Cd (II), four MILs were prepared and tested. Extraction parameters of the MIL-DLLME including pH, type and volume of the MIL, type and volume of dispersive solvent, extraction cycle, ionic strength and sample volume were investigated in detail and optimized by Box–Behnken design. Under optimum conditions, matrix effect, recovery study, intra-day and inter-day precision were performed for the MIL-DLLM. The analytical characteristics such as limit of detection, limit of quantification and pre-concentration factor were 0.17, 0.56 and 125 ng mL−1, respectively. The validation of the MIL-DLLME was evaluated by analysis of reference materials. Moreover, the accuracy of the results in the analysis of real samples was evaluated by standard addition and quantitative recoveries (91 ± 5–101 ± 2%) were achieved. The results obtained in the analysis of both reference materials and real samples showed that the MIL-DLLME has a selective applicability for cadmium.