Richard C. Levin, who has directed a vast expansion and modernization of Yale University, while improving relations with the city of New Haven and university finances, announced Thursday that he would step down as president at the end of the school year.


Mr. Levin, 65, is currently the most senior president in the Ivy League and one of the longest-serving in Yale’s history.


“These years have been more rewarding and fulfilling than I ever could have imagined,” he said in an e-mail to alumni Thursday morning. “My words on accepting my appointment as President are as true today as they were on April 15, 1993: ‘The greatness of this institution humbles me.'”


When Mr. Levin took office, Yale was being described as a university whose perch among the world’s top schools had grown shaky. The administration often battled the faculty members and the troubled surrounding city, there were budget shortfalls and staff cuts, applications were down, and facilities badly needed renovation and repair.


A search committee repeatedly postponed the deadline for naming a new president, reportedly settling unenthusiastically on the low-key Mr. Levin after being unable to find a more charismatic outsider. Almost two decades later, Yale’s academic reputation and its finances are more secure, and Mr. Levin, commonly called Rick, is among the most respected university leaders in the country.


Under him, the university has built a new business school campus; greatly expanded its facilities, including its science center and medical school; overhauled its buildings, including all 12 undergraduate residential colleges; started construction of two new residential colleges to make room for the first major expansion in undergraduate enrollment in decades; and embarked on new programs overseas.


His administration’s successful fund-raising has kept Yale’s endowment growing faster than those of its peers, despite heavy capital spending, and allowed the university to weather the last recession without the kinds of cuts that marked previous downturns. As of mid-2011, the endowment stood at $19.4 billion, second only to Harvard’s; when Mr. Levin took office, it was $3.2 billion, behind both Harvard and Princeton.


After decades of discord between Yale and New Haven, a city increasingly beset by crime and poverty, Mr. Levin made improved relations a priority. When asked what his first act as president would be, he replied that he would shake the mayor’s hand.


He developed a good working relationship with Mayor John DeStefano, Jr., who took office a few months after Mr. Levin became president, and Yale has taken part in efforts to renovate the city center and make it safer.


Benno C. Schmidt Jr., president from 1986 to 1992, battled the faculty over his moves to take decision-making powers away from them, his plans to make deep cuts in their ranks, and other issues. Hired from Columbia University and maintaining his residence in New York City, Mr. Schmidt was derided as an outsider, an absentee leader.


By contrast, Mr. Levin was a familiar, well-liked figure, a longtime Yale professor and administrator, whose wife, Jane, was an English professor there. He quickly improved faculty relations and has kept them relatively smooth during his tenure.


Even so, Yale’s long history of combative labor relations continued under Mr. Levin. In 2002 and 2003, clerical, maintenance and service workers went on strike, winning improved pay and pensions, and the university has fought a longstanding effort by graduate students who teach or do research to unionize.


Mr. Levin’s administration was also criticized in recent years by women’s groups who said the university was slow to recognize that it needed to be tougher on sexual harassment and sexual assault. Last year, the university overhauled its procedures and suspended a fraternity that had been involved in harassment incidents.


Private schools have come under fire for their fast-rising prices; under Mr. Levin, the sticker price for a year of undergraduate education at Yale, including tuition, room and board, and books, has more than doubled, to $58,600 for 2012-13. But most students receive financial aid, and Yale was among the first, in recent years, to replace student loans with grants, and to extend significant aid to students from middle- and upper-middle-income families.


Several Yale administrators who worked under Mr. Levin have gone on to head other colleges and universities.


Mr. Levin was born and raised in San Francisco, graduated from Stanford University and studied at Oxford University, where he crossed paths with another American, Bill Clinton. He earned a doctorate in economics from Yale in 1974 and stayed on to teach, eventually becoming chairman of the economics department, and dean of the Graduate School of Arts and Sciences.


In 2010, he was reported to be a candidate to be one of President Obama’s top economic advisers.