A critical branching process {Zk, k = 0, 1, 2, ...} in a random environment is considered. A conditional functional limit theorem for the properly scaled process {log Zpu, 0 ≤ u < ∞} is established under the assumptions that Zn > 0 and p ≪ n. It is shown that the limiting process is a Lévy process conditioned to stay nonnegative. The proof of this result is based on a limit theorem describing the distribution of the initial part of the trajectories of a driftless random walk conditioned to stay nonnegative.