To make CGE models realistic, inequality constraints (e.g., import quotas) or non-differentiable functions (e.g., income tax schedules) are sometimes needed. Both situations may be described using complementarity conditions, which state that either an equation is true or its complementary variable is at a boundary value. The paper describes a practical way to solve CGE models that contain such conditions. The technique, which is different from complementarity algorithms commonly used elsewhere (e.g., GAMS), has been implemented in the current version of the GEMPACK system, and has been used in a number of applications. This paper explains why the solution methods used in previous versions of GEMPACK do not handle complementarity conditions well, and describes how a two-pass procedure can overcome these difficulties. The key insight is that if we knew in advance which constraints would be binding in the accurate solution, the complementarity conditions could be reformulated in terms of smooth functions only, via a closure change which allows us to ignore the troublesome equations.