This paper deals with extinction of an isolated population caused by intrinsic noise. We model the population dynamics in a "refuge" as a Markov process which involves births and deaths on discrete lattice sites and random migrations between neighboring sites. In extinction scenario I, the zero population size is a repelling fixed point of the on-site deterministic dynamics. In extinction scenario II, the zero population size is an attracting fixed point, corresponding to what is known in ecology as the Allee effect. Assuming a large population size, we develop a WKB (Wentzel-Kramers-Brillouin) approximation to the master equation. The resulting Hamilton's equations encode the most probable path of the population toward extinction and the mean time to extinction. In the fast-migration limit these equations coincide, up to a canonical transformation, with those obtained, in a different way, by Elgart and Kamenev [Phys. Rev. EPHYADX1539-375510.1103/PhysRevE.70.041106 70, 041106 (2004)]. We classify possible regimes of population extinction with and without an Allee effect and for different types of refuge, and solve several examples analytically and numerically. For a very strong Allee effect, the extinction problem can be mapped into the overdamped limit of the theory of homogeneous nucleation due to Langer [Ann. Phys. (NY)APNYA60003-491610.1016/0003-4916(69) 90153-5 54, 258 (1969)]. In this regime, and for very long systems, we predict an optimal refuge size that maximizes the mean time to extinction.