Solar flares and coronal mass ejections are the most powerful explosions in the Sun. They are major sources of potentially destructive space weather conditions. However, the possible causes of their initiation remain controversial. Using high-resolution data observed by the New Solar Telescope of Big Bear Solar Observaotry, supplemented by Solar Dynamics Observatory observations, we present unusual observations of a small-scale emerging flux rope near a large sunspot, whose eruption produced an M-class flare and a coronal mass ejection. The presence of the small-scale flux rope was indicated by static nonlinear force-free field extrapolation as well as data-driven magnetohydrodynamics modeling of the dynamic evolution of the coronal three-dimensional magnetic field. During the emergence of the flux rope, rotation of satellite sunspots at the footpoints of the flux rope was observed. Meanwhile, the Lorentz force, magnetic energy, vertical current, and transverse fields were increasing during this phase. The free energy from the magnetic flux emergence and twisting magnetic fields is sufficient to power the M-class flare. These observations present, for the first time, the complete process, from the emergence of the small-scale flux rope, to the production of solar eruptions.