We consider the single-machine online scheduling with job rejection to minimize the total completion time of the scheduled jobs plus the total rejection cost of the rejected jobs under an agreeable condition on the processing times and rejection penalties of the jobs. In the problem, a set of independent jobs arriving online over time has to be scheduled on the machine with the flexibility of rejecting some of the jobs, where preemption is not allowed and the information of each job Jj, including its processing time pj, release date rj and rejection penalty ej, is not known in advance. The agreeable condition means that, for every two jobs Ji and Jj, pi<pj implies ei⩾ej, and furthermore, pi=pj and ri<rj imply ei⩾ej. For this problem, we provide an online algorithm with the best possible competitive ratio of 2. As a consequence, the online algorithm is also best possible when the jobs have identical rejection penalties.