We report temperature and magnetic-field dependence of flux pinning force in bulk MgB 2 with variable grain size. The samples are prepared by advanced methods, allowing minimizing effects of porosity, impurities, and inclusions of secondary phases. The effects of grain connectivity, flux-creep phenomena, and grain size on critical current density and flux pinning curves are analyzed. We have compared the field dependence of the pinning force for a range of samples with the predictions of theoretical models accounting for the effect of the grain size. There is qualitative agreement between grain-boundary pinning mechanism proposed by Hampshire and Jones ͓J. Phys. C 21, 419 ͑1987͔͒ and the experimentally observed grain-size dependence of pinning force in bulk MgB 2 .