A cost function for continuous-flow grain drying was developed, which relates grain moisture content, grain temperature and thermal damage, fuel used for drying and elapsed time to the cost of drying per tonne of output grain. A simplified model of a grain dryer was developed for rapid calculation of these parameters during simulation of unsteady-state drying. The cost function and dryer model were used in a long-range predictive control algorithm which, for each control action of an existing feedforward-plus-feedback system, determined and applied near-optimal values of target moisture content and drying air temperature. The complete system was tested using computer simulation of a mixed-flow dryer to represent a real dryer, and the overall cost of drying was compared with that given by a system with the lowest cost combination of a fixed target moisture content and drying air temperature. The system demonstrated a well-behaved response over a range of input grain moisture content from 0·20 to 0·30 dry basis and showed an 18% saving in time and a cost saving of 0·30 £ t −1. The cost incurred by grain recirculation and the problem of control instability caused by recirculation were also investigated.