Background: Icotinib, an oral EGFR tyrosine kinase inhibitor, had shown antitumour activity and favourable toxicity in early-phase clinical trials. We aimed to investigate whether icotinib is non-inferior to gefitinib in patients with non-small-cell lung cancer. Methods: In this randomised, double-blind, phase 3 non-inferiority trial we enrolled patients with advanced non-small-cell lung cancer from 27 sites in China. Eligible patients were those aged 18-75 years who had not responded to one or more platinum-based chemotherapy regimen. Patients were randomly assigned (1:1), using minimisation methods, to receive icotinib (125 mg, three times per day) or gefitinib (250 mg, once per day) until disease progression or unacceptable toxicity. The primary endpoint was progression-free survival, analysed in the full analysis set. We analysed EGFR status if tissue samples were available. All investigators, clinicians, and participants were masked to patient distribution. The non-inferiority margin was 1·14; non-inferiority would be established if the upper limit of the 95% CI for the hazard ratio (HR) of gefitinib versus icotinib was less than this margin. This study is registered with ClinicalTrials.gov, number NCT01040780, and the Chinese Clinical Trial Registry, number ChiCTR-TRC-09000506. Findings: 400 eligible patients were enrolled between Feb 26, 2009, and Nov 13, 2009; one patient was enrolled by mistake and removed from the study, 200 were assigned to icotinib and 199 to gefitinib. 395 patients were included in the full analysis set (icotinib, n=199; gefitinib, n=196). Icotinib was non-inferior to gefitinib in terms of progression-free survival (HR 0·84, 95% CI 0·67-1·05; median progression-free survival 4·6 months [95% CI 3·5-6·3] vs 3·4 months [2·3-3·8]; p=0·13). The most common adverse events were rash (81 [41%] of 200 patients in the icotinib group vs 98 [49%] of 199 patients in the gefitinib group) and diarrhoea (43 [22%] vs 58 [29%]). Patients given icotinib had less drug-related adverse events than did those given gefitinib (121 [61%] vs 140 [70%]; p=0·046), especially drug-related diarrhoea (37 [19%] vs 55 [28%]; p=0·033). Interpretation: Icotinib could be a new treatment option for pretreated patients with advanced non-small-cell lung cancer. Funding: Zhejiang Beta Pharma (China), the Chinese National Key Special Program for Innovative Drugs, the 863 Project, and Zhejiang Provincial Key Special Program.