We discuss pinning properties of MgB2 thin films grown by pulsed-laser deposition (PLD) and by electron-beam (EB) evaporation. Two mechanisms are identified that contribute most effectively to the pinning of vortices in randomly oriented films. The EB process produces low defected crystallites with small grain size providing enhanced pinning at grain boundaries without degradation of Tc. The PLD process produces films with structural disorder on a scale less that the coherence length that further improves pinning, but also depresses Tc.