One of these phrase
s that alters its meaning entirely as you travel across the Atlantic
Originally public schools were set up for any member of the public (who had the necessary cash available) to send their progeny to, or who were favoured by endowment.
Back in mediaeval times, this pretty much restricted pupils to sons of the rich merchant classes and minor gentry - the sons of aristocracy were, of course, home schooled.
As the schools expanded, they expanded only the pupil numbers in the fee-paying intake, whose families paid the tuition fees.
As an example, Eton was founded by the King, Henry VI in 1440 - originally for teaching pupils funded by endowment. (The tradition continues - approximately 70 of the 1100 pupils at Eton remain funded via endowment).
As primary education became provided as a statutory right in England in the Eighteenth century, a new system of state schools was created, used by all members of the public, rather than merely being open to all members of the public in a theoretical way.
In the nascent United States of America, the naming was applied to those schools funded out of the public purse.
This has led to the current situation where in England a public school refers to an independent fee-paying school, and in the United States of America public school refers to a government-run school, free at the point of use.
To address specific points raised: In England, grammar schools are state schools
which select their pupils based on ability, but which are not fee-paying, thereore do not need the specific exclusion given by Darl.
Additionally, 'public school' is an England-specific term, not a UK-wide term.