Strathclyde Police said that up to 11 Auchinleck Academy pupils, aged between 12 and 16, were injured - none of them seriously.
The incident happened in the town's Church Street, just after 1330 GMT.
An 18-year-old boy and a 15-year-old boy are expected to appear at Ayr Sheriff Court later, on charges of assault.
Five girls and six boys were struck by pellets, mainly on their legs and torsos.
It is understood one pupil remains in Crosshouse Hospital, near Kilmarnock.
Firearms officers were called to the scene on Wednesday afternoon and East Ayrshire Council informed parents of those pupils injured.
At least one property nearby had its windows shattered by pellets. It is understood police are still looking for a weapon and further charges, connected with firearms, may be brought.
East Ayrshire Council said it had responded immediately by informing police and parents of the children involved and seeking medical attention.
In a statement it said: "The council is working closely with the school to ensure that the school, the children and their families are appropriately supported."
This post was made using the Auto Blogging Software from WebMagnates.org This line will not appear when posts are made after activating the software to full version.