The high performance liquid chromatography (HPLC)-triple quadrupole tandem mass spectrometry was applied for the determination of the aflatoxins: B1 (AFB1), B2 (AFB2), G1 (AFG1) and G2 (AFG2), in cereals and oils. The samples were first extracted by ultrasonic method. The optimized conditions of ultrasonic extraction were as follows: temperature of 50 degrees C, extraction time of 3 min, methanol-water (containing 40 g/L NaCl) (80: 20, v/v) solution as the medium and a ratio of sample to solvent of 1 : 3 (g: mL). The extracts were then purified using an immunoaffinity column. The separation was performed on a C18 column with mobile phases of 10 mmol/L ammonium acetate and methanol in gradient elution. The sensitive detection of the four AFT compounds by electrospray ionization mass spectrometry (ESI-MS) was carried out in selected reaction monitoring (SRM) mode with aflatoxin M1 (AFM1) as the internal standard. Under the optimized conditions, the limits of detection of AFB1, AFB2, AFG1 and AFG2 were 0.002, 0.004, 0.004 and 0.012 microg/kg, respectively. The recoveries of aflatoxins in different spiked cereals and oils were in the range from 87% to 111%. The intra-day and inter-day precisions were not more than 6.7% and 5.6%, respectively. In comparison with the external standard method, this method can effectively inhibit the matrix effects, and greatly improve the accuracy.