We perform high-resolution cosmological hydrodynamic simulations to study the formation of the first galaxies that reach the masses of 108 - 9 h-1 M⊙ at z = 9. The resolution of the simulations is high enough to resolve minihaloes and allow us to successfully pursue the formation of multiple Population (Pop) III stars, their supernova (SN) explosions, resultant metal-enrichment of the inter-galactic medium (IGM) in the course of the build-up of the system. Metals are ejected into the IGM by multiple Pop III SNe, but some of the metal-enriched gas falls back on to the halo after $\gtrsim 100~\rm Myr$. The star formation history of the first galaxy depends sensitively on the initial mass function (IMF) of Pop III stars. The dominant stellar population transits from Pop III to Pop II at z ~ 12-15 in the case of power-law Pop III IMF, dn/dM ∝ M-2.35 with the mass range 10-500 M⊙. At z ≲ 12, stars are stably formed in the first galaxies with a star formation rate of ~10-3-10-1 M⊙ yr -1. In contrast, for the case with a flat IMF, gas-deprived first galaxies form due to frequent Pop III pair-instability SNe, resulting in the suppression of subsequent Pop II star formation. In addition, we calculate UV continuum, Lyα- and Hα-line fluxes from the first galaxies. We show that the James Webb Space Telescope will be able to detect both UV continuum, Lyα and Hα line emission from first galaxies with halo mass ≳ 109 M⊙ at z ≳ 10.