Maryland Superintendent of Schools Nancy S. Grasmick announced Wednesday that she will retire at the end of June, ending two decades at the helm of a state school system that has won national recognition as an educational powerhouse.

One of the nation’s longest-serving state school chiefs, Grasmick weathered feuds with governors and local superintendents over education policy. She became known for pushing to test students to assess school performance, carrying out the federal No Child Left Behind law with zeal.

“I’m proud of working with the educational community to achieve high results,” said Grasmick, 72. “But it’s been 20 years and we’re on top, and I think we are positioned very well to have a successor.”

Grasmick envisioned that a student’s education cycle would begin and end with exams. She instituted the High School Assessments, a must-pass battery of exams she hoped would ensure that every graduate would be ready for college or a career. She has championed early-childhood assessments, setting standards for students to be deemed “ready to learn” for kindergarten.

She has said that the testing has led to better schools. The state has the highest percentage of students who have passed at least one Advanced Placement exam. In January, Education Week ranked Maryland ahead of all other states for K-12 education policy and performance for the third year in a row.

But some numbers aren’t so sterling. One recent study found that half of the state’s graduates needed remedial math as college freshmen. Education Week noted that on federal tests in 2009, Maryland’s fourth-graders trailed 14 states in math proficiency and eight states in reading.

Prince George’s County Superintendent William R. Hite Jr., who leads one of the state’s most uneven school systems, praised Grasmick’s recent push for better teacher evaluations, saying they “put the district on the path to reform.”

Appointed in 1991 by the State Board of Education, Grasmick is surpassed in tenure among state schools chiefs only by North Dakota Superintendent of Public Instruction Wayne G. Sanstead.

In Maryland, Grasmick’s name is an institution: The state education building in Baltimore is named after her. U.S. Sen. Benjamin L. Cardin (D-Md.) called her “the heart and soul of Maryland’s public school system for 20 years.” By her own count, Grasmick often journeyed 600 miles a week to visit schools and attend meetings across the state.

Grasmick, a Democrat, served under four governors, starting with William Donald Schaefer (D). Gov. Parris N. Glendening (D) told The Washington Post in 2007 that he had tried to work around Grasmick because she was “almost obsessed” with testing, “to the point of neglecting things I thought were even more important.”

Gov. Robert L. Ehrlich Jr. (R) formed an alliance with Grasmick. Gov. Martin O’Malley (D) tried to oust her but failed.

O’Malley’s feud with Grasmick dated to his tenure as mayor of Baltimore.

In his successful 2006 campaign to unseat the incumbent Republican governor, O’Malley accused Grasmick of “doing Ehrlich’s bidding” and being “a pawn” of the state GOP by seeking to embarrass him over the low performance of Baltimore schools. That year, Grasmick had sought to seize control of 11 struggling Baltimore schools, citing authority under the No Child Left Behind law. But the Democratic-controlled legislature blocked her action.

After O’Malley was elected, the State Board of Education, which was still controlled by Ehrlich appointees, moved to extend Grasmick’s term as superintendent by four years — despite objections by O’Malley and state Senate President Thomas V. Mike Miller Jr. (D-Calvert).

But O’Malley and Grasmick appeared to set their differences aside.

On Wednesday, O’Malley issued as statement thanking Grasmick for her service, wishing her well and noting that she had “been long regarded as a champion for many of the progressive reforms we’ve implemented in Maryland.”

Grasmick also sparred with Montgomery County Superintendent Jerry D. Weast last year over the state’s application for a federal Race to the Top school reform grant. Ultimately the state won the grant, which will fund an initiative to tie teacher evaluation to student test scores, without Montgomery’s participation.

In a statement Wednesday, Weast praised Grasmick’s “distinguished record of service to the students.”

The state school board will soon begin to search for a replacement, spokesman William Reinhard said. But the board’s search process is yet to be determined.

“They have not had to do this in 20 years,” Reinhard said.

Staff writer John Wagner contributed to this report.