A nonsmooth optimization control (NOC) based on a sandwich model with hysteresis is proposed to control a micropositioning system (MPS) with a piezoelectric actuator (PEA). In this control scheme, the hysteresis phenomenon inherent in the PEA is described by a Duhem submodel embedded between two linear dynamic submodels that describe the behavior of the drive amplifier and the flexible hinge with load, respectively, thus constituting a sandwich model with hysteresis. Based on this model, a nonsmooth predictor for sandwich systems with hysteresis is constructed. To avoid the complicated online search for the optimal value of the generalized gradient at a nonsmooth point, the method of the so-called weighted estimation of generalized gradient is proposed. In order to compensate for the model error caused by model uncertainty, a model error compensator (MEC) is integrated into the online optimization control strategy. Afterwards, the stability of the control system is analyzed based on Lyapunov’s theory. Finally, the proposed NOC-MEC method is verified on an MPS with a PEA, and the corresponding experimental results are presented.