Under the new rules, pupils at state and private primary schools will be barred from using phones and other devices capable of communication, audio or video recording.
The ban applies not just in lessons, but during breaks and other school activities, including off-site classes such as PE lessons held at external sports facilities.
The same restriction covers pre-school children while on school or nursery premises.
There are some exceptions: a teacher may allow device use for lessons or tests, in urgent cases where a pupil needs to contact their parents, or where there is a direct threat to health or life.
Head teachers may also grant permission for pupils and pre-schoolers to use a device on medical or disability grounds, or where specialist equipment or a health-monitoring app is required.
Any refusal to agree to such a request must be issued in writing.
Schools will be allowed to set up dedicated storage areas for pupils' devices, designed to keep them secure and to protect privacy, with detailed rules left to individual head teachers.
Pupils who break the rules may face disciplinary measures or sanctions set out in their school's regulations, which could also affect their conduct grades.
The ban does not apply to secondary education, such as general or vocational schools, or institutions for adult learners.
These will each be required to set their own device-use rules, or ban phones outright, in their statutes.
Nor does it apply during school trips or in boarding accommodation, where this is similarly left to individual schools.
The measure takes effect on September 1.
Schools have until December 31 to update their internal regulations accordingly.
The law was backed by representatives of all parties in parliament.
(ał)
Source: PAP