The drinking water in Flint, Mich., is now in compliance with federal regulations on lead and copper content, officials said on Tuesday. But they cautioned that it could be a year or more before it is safe for residents to drink from their faucets, because lead-tainted pipes need to be replaced.

“We are not out of the woods yet,” Mayor Karen Weaver said in a statement. She called the results of water tests “encouraging” but said residents should continue to drink bottled water or use filters.

She said that the city was making progress toward its goal of removing an estimated 20,000 lead-tainted water pipes and that it hoped to replace 6,000 of them by the end of the year.

“We still need help and support from the state and federal government so that all of the estimated 20,000 lead-tainted pipes remaining in the city will be replaced,” Ms. Weaver said. Until then, free bottled water and filters will continue to be available at distribution points around the city, she said.