In a bit more detail there were two 'classes' of grammar schools. The state (actually local authority) system had grammar schools for those who passed an exam and secondary modern (technical schools) for those who did not. The grammar schools were modelled on the public school system one played rugby and learnt Latin +/- Greek. At a secondary modern soccer was played and more practical subjects were studied. (Girls schools were similar, though sports were not such a dichotomy.)
There was a second class of grammar schools, usually belonging to a charitable foundation sometimes religious and sometimes others (well known examples in England would be e.g. Merchant Taylor's school, Haberdasher's) they would set their own exams, school fees would be paid for those who passed on a means tested basis - direct grant schools; some are now entirely free and funded by the state some moved in the opposite direction and are entirely private. An example of the latter is King Edward VI School that was a major route to success for academic girls from Birmingham when it was direct grant, now it has become more exclusive. Many women in STEM from Birmingham would have come from KE6, it was a major feeder for working class girls to Oxbridge. I am sure it is still a great school, but more exclusive. There are scholarships, but since they are from the school funds they are more restricted than they used to be. I went to a similar school in Yorkshire. These would be contiguous with 'Public' schools. Someone who attended a 'grammar' school could have attended a state school or a 'minor' public school.
There are also state boarding schools.