Complex traits often involve interactions between different genetic loci. This can lead to sign epistasis, whereby mutations that are individually deleterious or neutral combine to confer a fitness benefit. In order to acquire the beneficial genotype, an asexual population must cross a fitness valley or plateau by first acquiring the deleterious or neutral intermediates. Here, we present a complete, intuitive theoretical description of the valley-crossing process across the full spectrum of possible parameter regimes. We calculate the rate at which a population crosses a fitness valley or plateau of arbitrary width, as a function of the mutation rates, the population size, and the fitnesses of the intermediates. We find that when intermediates are close to neutral, a large population can cross even wide fitness valleys remarkably quickly, so that valley-crossing dynamics may be common even when mutations that directly increase fitness are also possible. Thus the evolutionary dynamics of large populations can be sensitive to the structure of an extended region of the fitness landscape - the population may not take directly uphill paths in favor of paths across valleys and plateaus that lead eventually to fitter genotypes. In smaller populations, we find that below a threshold size, which depends on the width of the fitness valley and the strength of selection against intermediate genotypes, valley-crossing is much less likely and hence the evolutionary dynamics are less influenced by distant regions of the fitness landscape.