Sr$_2$RuO$_4$ is a leading candidate for chiral $p$-wave superconductivity. The detailed mechanism of superconductivity in this material is still the subject of intense investigations. Since superconductivity is sensitive to the topology of the Fermi surface (the contour of zero-energy quasi-particle excitations in the momentum space in the normal state), changing this topology can provide a strong test of theory. Recent experiments tuned the Fermi surface topology efficiently by applying planar anisotropic strain. Using functional renormalization group theory, we study the superconductivity and competing orders in Sr$_2$RuO$_4$ under strain. We find a rapid initial increase in the superconducting transition temperature $T_c$, which can be associated with the evolution of the Fermi surface toward a Lifshitz reconstruction under increasing strain. Before the Lifshitz reconstruction is reached, however, the system switches from the superconducting state to a spin density wave state. The theory agrees well with recent strain experiments showing an enhancement of $T_c$ followed by an intriguing sudden drop.