We present a renormalization-group study of the order-parameter distribution function near the critical point of O(n) symmetric three-dimensional (3D) systems in a finite geometry. The distribution function is calculated within the φ4 field theory for a 3D cube with periodic boundary conditions by means of a novel approach that appropriately deals with the Goldstone modes below T c . Results are given for both vanishing and finite external field h. The results describe finite-size effects near the critical point in the h– T-plane including the first-order transition at the coexistence line at h = 0 below T c . Quantitative theoretical predictions of the finite-size scaling function are presented for the Ising (n=1), XY(n=2) and Heisenberg (n=3) models. Good agreement is found with recent Monte Carlo data.