The mayor also has expressed frustration that student performance has not improved quickly enough. In an interview last week with CommonWealth magazine — before Mr. Chang’s resignation was made public — Mr. Walsh was blunt. “They’re not performing anywhere near where they need to be,” the mayor said of the district’s open-enrollment high schools.

In a farewell message on the Boston Public Schools website, Mr. Chang said the schools had made improvements under his leadership. He said that graduation rates had increased to 72.7 percent in 2017 from 70.7 percent in 2015, and dropout rates had dropped to 3.6 percent last year from 4.4 percent in 2015.

Last week, the city and Mr. Chang were sued by civil rights groups that say the school district appeared to be giving information to federal immigration authorities. In one case, the lawsuit said, information from the district — a report by a school police officer — was used as evidence in deportation proceedings against a high school student.

Nearly half of the Boston school district’s 56,000 students — who come from about 140 countries — speak a language other than English at home. School systems are barred from asking students about their immigration status.

In a letter issued on Monday, Mr. Chang, who immigrated to the United States from Taiwan as a child, said the schools had no practice of providing student records to Immigration and Customs Enforcement. But, he said, the district had complied with requests from law enforcement agencies that were “investigating gang-related murders in East Boston over two years ago and provided relevant school police reports, which did not contain any student immigration information.”

Matthew Cregor, a staff attorney with the Lawyers’ Committee for Civil Rights and Economic Justice, one of the plaintiffs in the suit, said that while the committee was focused on city policy and not on Mr. Chang, his letter nonetheless raised concern. “There are exceptions to federal education privacy laws that allow for some information sharing,” he said, but the letter suggests “the city is speaking out of both sides of its mouth.”

Some national news reports suggested that the lawsuit had led to Mr. Chang’s departure. But the mayor and Mr. Chang had met last week, before the suit was filed, and had already agreed on Mr. Chang’s departure, according to a city official who requested anonymity to discuss a personnel matter.