Abstract We propose a mechanism for quasi-periodic oscillations of both coronal mass ejections (CMEs) and flare loops as related to magnetic reconnection in eruptive solar flares. We perform two-dimensional numerical MHD simulations of magnetic flux rope eruption, with three different values of the global Lundquist number. In the low Lundquist number run, no oscillatory behavior is found. In the moderate Lundquist number run, on the other hand, quasi-periodic oscillations are excited both at the bottom of the flux rope and at the flare loop top. In the high Lundquist number run, quasi-periodic oscillations are also excited; in the meanwhile, the dynamics become turbulent owing to the formation of multiple plasmoids in the reconnection current sheet. In high and moderate Lundquist number runs, thin reconnection jets collide with the flux rope bottom or flare loop top and dig them deeply. Steep oblique shocks are formed as termination shocks where reconnection jets are bent (rather than decelerated) in the horizontal direction, resulting in supersonic backflows. The structure becomes unstable, and quasi-periodic oscillations of supersonic backflows appear at locally confined high-beta regions at both the flux rope bottom and flare loop top. We compare the observational characteristics of quasi-periodic oscillations in erupting flux ropes, post-CME current sheets, flare ribbons, and light curves with corresponding dynamical structures found in our simulation.