Transonic buffet is a phenomenon of aerodynamic instability with shock wave motions which occurs at certain combinations of Mach number and mean angle of attack, and which limits the aircraft flight envelope. The objective of this study is to develop a modelling method for unstable flow with oscillating shock waves and moving boundaries, and to perform model-based feedback control of the two-dimensional buffet flow by means of trailing-edge flap oscillations. System identification based on the ARX algorithm is first used to derive a linear model of the input–output dynamics between the flap rotation (the control input) and the lift and pitching moment coefficients (system outputs). The model features a pair of unstable complex-conjugate poles at the characteristic buffet frequency. An appropriate reduced-order model (ROM) with a lower dimension is further obtained by a balanced truncation method that keeps the pair of unstable poles in the unstable subspace but truncates the dynamics in the stable subspace. Based on this balanced ROM, two kinds of feedback control are designed by pole assignment and linear quadratic methods respectively. These independent designs, however, result in similar suboptimal static output feedback control laws. When introduced in numerical simulations, they are both able to completely suppress the buffet instability. Furthermore, the resulting controllers are even able to stabilize buffet flows with nonlinear disturbances and in off-design flow conditions, thus implying their robustness. The analysis of the feedback control laws indicates that parameters (frequency and phase) corresponding to the ‘anti-resonance’ of the linear input–output model are vital for optimal control. The best performance is obtained when the control operates close to the ‘anti-resonance’, which is supported by the optimal frequency and the phase of the open-loop control as well as by the optimal phase of the closed-loop control.