Three members of the gendarmerie were injured in Oye-Plage outside Calais on France's northern coast, prosecutors in the town of Saint Omer said late on Thursday.
They were patrolling the beach in all-terrain vehicles on Thursday morning when the migrants threw stones at them.
The windshield of one of the buggies shattered and then and swerved into soft sands "causing it to roll over," prosecutors told AFP.
The migrants continued their attack on the three gendarmes stuck in the buggy "before a rapid intervention by their colleagues to free them."
The three sustained wounds including to the head but have not been hospitalized.
London has repeatedly accused Paris of not doing enough to stop migrants crossing the Channel in small boats. French officials insist they do seek to stop them on shore.
The right-wing Conservative government of British Prime Minister Rishi Sunak has made a priority of stopping the small boat crossings but people are continuing to undertake the journey on an almost daily basis.
In November 2021, 27 migrants died when their boat capsized in the Channel. On Thursday, French authorities charged five military personnel over failing to come to their aid.