Hit the books, Mr. Mayor!

A Queens state senator has introduced legislation that repudiates Mayor Bill de Blasio’s controversial push to scrap New York’s specialized high schools admissions exam.

Instead, Sen. Leroy Comrie is proposing the creation of an additional 10 specialized high schools, expanding free SHSAT test prep to cover every sixth and seventh grader and requiring that all eighth graders take the exam unless their parents opt out.

The bill also proposes a commission to recommend improvements to New York City middle schools and would create a Gifted & Talented program in each district.

“Students in every district deserve access to early age [Gifted & Talented programs], publicly funded test prep and a specialized high school close to where they live. That is exactly how we fix this problem,” said the Rev. Kirsten John Foy, who leads the big-spending Education Equity Campaign.

The group has battled City Hall to keep the specialized exam, which currently determines admission to eight of the city’s top high schools.

“This bill will do all those things and focus the attention we need on improving our under-served middle schools.”

Additionally, the legislation would require every school district in the city to offer advance courses for students through gifted and talented programs.

It would also establish a commission to study the city’s middle schools and recommend improvements.

Comrie’s bill would be paid for by the city, but a cost estimate was not immediately available.

“Mayor de Blasio and education experts have been clear: a single test on a single day shouldn’t determine any child’s future,” said mayoral spokesman Will Baskin-Gerwitz. “He remains focused on working hand in hand with allies in Albany to pass real reform that accomplishes the goal of eliminating the SHSAT.”