Education Secretary Arne Duncan, who dramatically expanded the federal role in education and compelled changes in the nation’s 100,000 public schools, surprised even close associates Friday by announcing that he will resign in December.

Duncan, 50, the ­longest-serving member of President Obama’s Cabinet and a close friend of the president, cajoled and pressured states to enact policies that angered teachers unions on the left and ­small-government conservatives on the right.

“He’s done more to bring our educational system, sometimes kicking and screaming, into the 21st century than anyone else,” Obama said during remarks at the White House on Friday, in a nod to the controversy that has swirled around some of Duncan’s agenda. “America will be better off for what he has done.”

Duncan’s departure means Obama is losing his closest confidant in the Cabinet, a buddy who comes from their beloved Chicago, who has known Obama for decades and who is a listener in a town known for talkers.

President Obama has tapped John King Jr., shown here speaking to students at New York University in 2014, to run the Education Department. Education Secretary Arne Duncan is stepping down in December. (Michael Sisak/AP)

The Duncans have been regular guests of the Obamas for weekends at Camp David and at pool parties and Super Bowl gatherings at the White House. The president and his education secretary talk policy and personal life during spontaneous lunchtime burger runs.

And then there is basketball. Obama and Duncan met in the early 1990s on the hardwoods in Chicago and bonded through a love of the game and a shared interest in education. Until the president recently gave up basketball for golf, Duncan was a mainstay at pickup games at courts at the FBI and various federal outposts around town.

The affection between Obama and Duncan was clear at the White House on Friday.

“Arne Duncan is one of my longest-serving Cabinet secretaries, and he’s been a friend for a lot longer than that,” Obama said, going on to chide Duncan, a 6-foot-5 onetime professional basketball player in Australia. “He’s my favorite partner in pickup basketball, the smartest player I know, even though he’s slow and has no hops.”

Duncan choked back tears as Obama put a supportive hand on his back. “I’ve cried more today than I have in a while,” Duncan said.

“I’ve loved this work, I love this team, I love the president, I love the chance to serve,” he said, as he gazed at his wife, Karen, and children, Claire and Ryan, who moved back to their home town of Chicago in June but traveled to Washington for the announcement. “The only thing I love more is you guys. And I can’t wait to come home.”

When Duncan floated the idea of resigning, Obama said he would not hear of it. “I’ll be honest, I pushed Arne to stay,” he said. “But I know from personal experience how hard it is to be away from your family on a sustained basis. So, while I will miss Arne deeply, he’s more than earned the right to return home.”

Duncan is a Chicago native who grew up around his mother’s South Side after-school tutoring center for poor children before going to Harvard University. He came to office determined to use federal power to force states and cities to improve education for low-income children.

He largely bypassed Congress to induce states to adopt landmark changes that none of his predecessors attempted, policies such as teacher evaluations and higher academic standards.

Duncan tried to straddle the deep national divide about the best way to improve public schools, working between those who believe that competition, accountability and market forces are the best route and others who argue for heavier investment and better distribution of dollars to help children from poor families.

To Duncan, that has meant a rapid expansion of public charter schools; promoting a national set of K-12 academic benchmarks known as the Common Core State Standards in math and reading; holding teachers accountable in part by student test scores; enrolling more low-income children in preschool; and investing in “wraparound services,” such as medical care, mentoring and family services.

By pushing so aggressively, Duncan triggered a political backlash that now threatens to undermine his efforts. Legislation pending in Congress would strip much of the education secretary’s authority and shift power from the federal government back to the states.

Progress for the nation’s K-12 students has been uneven during Duncan’s tenure. High school graduation rates are at an all-time high while dropout rates are down. But average math and reading scores for high school students have flat-lined since 2008, and the same scores have only marginally improved among 9- and 13-year-old students, according to federal tests.

To succeed Duncan, Obama has tapped John B. King Jr., who joined the education department in January as Duncan’s deputy after a turbulent tenure as commissioner of education for New York state.

A Brooklyn native who was orphaned at age 12, King often credits teachers for keeping him on a path that led him to earn a bachelor’s degree at Harvard, a law degree at Yale University and a doctorate in education at Columbia University. He later co-founded a high-performing charter school in Boston and led another network of charters in New York.

“New York City public school teachers are the reason I’m alive,” King said at the White House.

As state commissioner, King implemented teacher evaluations tied to test scores and pushed New York to adopt new tests aligned to the Common Core years before other states. That made him a target of public outrage. Test scores fell, and teachers unions called for his ouster.

Randi Weingarten, president of the American Federation of Teachers, said her union was “deeply disappointed” that King was appointed.

Meryl Tisch, chancellor of the New York State Board of Regents, said King disrupted a complacent bureaucracy in New York. “He put a lot of pressure on a very large system that had stagnated for quite a number of years,” she said.

Jeffrey Henig, a professor of political science and education at Teachers College at Columbia University, said King is similar to Duncan. “They draw on the same ideas and speak to the same groups,” he said.

Duncan used two powerful tools during his tenure: competitive federal grants known as Race to the Top; and waivers that excused states from the requirements of No Child Left Behind, a federal law widely disliked by states. To compete for a grant under Race to the Top, or to receive a waiver under No Child Left Behind, states had to adopt Duncan’s favored policies.

More than 40 states hold such waivers, leading critics such as Sen. Lamar Alexander (R-Tenn.) to accuse Duncan of acting as “the national school superintendent.”

In an important but little-heralded move, Duncan used $100 billion in stimulus funds to save 350,000 teaching jobs in the wake of the 2008 recession. His civil rights division aggressively investigated sexual assault on college campuses, and he pushed schools to fix discipline policies that disproportionately affect minority children.

In recent years, Duncan pushed unsuccessfully for a major expansion of federally funded preschool programs.

Duncan also has tried to leave a mark on higher education, working to widen access to college for disadvantaged students by simplifying financial aid forms and adding funding for Pell grants. He tightened oversight of for-profit colleges, leading to the collapse of the Corinthian College chain. A lengthy effort to rate colleges on measures of value and access was derailed, but Duncan last month unveiled an alternative: a federal Web site called College Scorecard that publishes information about graduation rates, average debt load and salaries of graduates at thousands of schools.

Duncan did not hide his dislike for the nation’s capital, often criticizing Washington as a den of dysfunction.

In an interview with The Washington Post in June, he recounted how one senator confided that he supported universal preschool — an idea Duncan had been promoting for two years — but would not publicly back any plan for the federal government to fund it.

“That’s, like, my political lesson in Washington,” Duncan said. “Are you here to make a difference? . . . Or are you here to say you’re a fancy senator?”

Nick Anderson and Juliet Eilperin contributed to this report.