Matthew D. Gallagher, the chief of staff to Maryland Gov. Martin O’Malley (D), plans to depart in June to take a job leading a philanthropic foundation in Baltimore.

The Goldseker Foundation announced the move late Wednesday night, and it was confirmed by Gallagher, who has served as an aide to O’Malley since 2000, when he was mayor of Baltimore.

Gallagher, who oversees the day-to-day operations of the governor’s office, is the latest in a string of high-ranking aides to depart as O’Malley approaches the end of his second term and weighs a 2016 presidential bid. In recent months, the governor’s chief lobbyist and director of public affairs also left for private-sector jobs.

Gallagher, 40, has been named the next president and chief executive officer of the Goldseker Foundation, which invests in community and economic development projects in the Baltimore region.

“It was a very difficult decision because it has been an incredible privilege to serve in city and state government,” Gallagher said. “Oftentimes these type of opportunities only come along once in a generation. As someone who was born and raised in Baltimore, it was very special chance to focus on issues about which I care deeply in a place I still call home.”

Gallagher is succeeding Timothy D. Armbruster, who is retiring after a 34-year tenure as head of the foundation.

During O'Malley’s tenure as mayor, Gallagher was director of CitiStat, a program that used an array of data to track performance of city agencies. It has been replicated at the state level and copied by numerous local governments around the country.

Gallagher came to Annapolis with O’Malley in 2007 as his deputy chief of staff and was elevated to his current post in 2009. He is widely regarded as an even-tempered manager with an encyclopedic knowledge of state government and fiscal issues.

“Matt Gallagher has built an exceptional career as a leader and champion in Baltimore City and across the region,” Sheldon Goldseker, chairman of the foundation, said in a statement.