A stochastic model has been developed for the hierarchical fragmentation of a molecular cloud. Here, the number of fragments, time between successive fragmentation steps, and mass of a fragment are considered as random variables, and fragment masses are generated using the Metropolis-Hastings algorithm. The resulting mass spectra, computed at different projected distances and taking opacity into consideration, show a signature of mass segregation. The critical mass, mass spectrum, and mass segregation are consistent with the observations of young massive clusters in our Galaxy as well as in external galaxies. © 2011. The American Astronomical Society. All rights reserved.