Ymir Fritz created the first Titan, the Founding Titan, and from her power the Nine Titans emerged. The common storyline is that Ymir gained the Titan power around 2,000 years before the main events, and after her death the power was passed down through her descendants, eventually becoming the Nine Titans and the basis for Eldian monarchic power. In short: Ymir Fritz is the origin point for the Titans in Attack on Titan. This power was subsequently inherited by others, forming the Nine Titans and linking to the royal-blood line for certain abilities.
