When the Prince William Board of County Supervisors jumped into the national immigration debate in 2007 and became one of the first places in the country to require the police department to question residents about their immigration status, Chief Charlie T. Deane thought otherwise.

He feared cries of racial profiling and losing the trust of the county’s growing immigrant community. His stance angered his bosses on the county board and many residents who thought he was flouting the law. But Deane, who announced his retirement on Wednesday, used his decades of goodwill to persuade the board to change its policy. The department would check a person’s immigration status only after an arrest.

“When this was forced on us, we had no experience with it, and there were legal and moral implications,” Deane said. “I saw from the beginning that the safest course for this county was to do the screening post-arrest. . . . We are responsible for providing police services to everyone, regardless of their status.”

Deane has earned a national reputation for the same straightforward approach he displayed during the immigration debate and for calm during crisis — hallmarks of his 24-year tenure as chief in Prince William. A firm, Southern gentleman, Deane has led his department through monumental change in both the county and in policing, maintaining his country sensibilities while facing the challenges of a modern, fast-growing community.

Just shy of his 67th birthday, Deane plans to leave, 42 years after he helped open the department in what was then a sleepy Virginia outpost of dairy farms. Although Prince William has become a bustling Washington bedroom community, the police department’s one constant has been Deane. Many in the county said Wednesday that it is the end of an era.

“Prince William has been a very exciting, dynamic place to work,” Deane said in an interview this week before he announced his retirement. “It’s just as exciting today. The challenges are different, and the world is more complex. But we’ve developed a department that is second to none, and it’ll be in good hands.”

Law enforcement officials across the country consider Deane one of the best in the field, having distinguished himself on the immigration issue but also for leading his department through some of the most notable crimes in the region’s history, including the Washington area sniper shootings, the “East Coast Rapist” investigation and the 1993 Lorena Bobbitt case.

When Deane began as chief in Prince William, the county had 200,000 residents. Cellphones barely existed, police didn’t have DNA evidence and the Internet — and the crimes created by it — was barely imaginable. Deane had 239 officers and a budget of $16 million.

Prince William has since doubled in population. The county is now home to Potomac Mills mall and a large concert venue. Police cars have computers and license-plate readers, the department has its own training academy and forensics lab, and Deane has diversified what is now a force of nearly 600 sworn officers and a budget of $80 million.

Through all the change, Deane made few, if any, enemies.

Philadelphia Police Commissioner Charles H. Ramsey, who was the District’s police chief from 1998 to 2006, said he thinks that Deane is “one of the greatest police chiefs in America.”

“Law enforcement has really grown by leaps and bounds over the past 24 years,” Ramsey said. “It has been a tremendous transformation, but people like Charlie Deane can adjust, adapt and grow with those changes.”

The county has seen its share of difficult issues: the crack epidemic, numerous capital-murder cases, abuse of prescription painkillers, a massive suburban marijuana ring and gang activity.

But the one that shook Deane, and most others in the region, was the sniper case in October 2002, in which 10 people were killed and at least three others seriously injured. Deane said he felt like a commander in a war zone, trying to solve one homicide while waiting for the next one. He said he treated it just as any other crime, but he kept an aerial photograph of one of the crime scenes — at a Manassas gas station — on his conference table, went to the gun range to hear the sound of a .223-caliber rifle (which was used in the crimes) and had trouble sleeping while the shootings continued.

“Charlie was a stabilizing factor for all of us during that time,” Ramsey said.

Deane has earned a reputation for being nearly unflappable, handling crises in a no-nonsense manner. Deane regularly appeared at crime scenes and often called on his background as a criminal investigator.

Prince William Commonwealth’s Attorney Paul B. Ebert said that Deane has embodied the principles of honesty and integrity, evidenced by the fact that there has never been a major scandal unearthed at the department.

“He insists on everyone in his department being good policemen, and he won’t tolerate dishonesty,” Ebert said.

Deane said he has fired police officers for lying to him. And he has been willing to air the department’s dirty laundry when necessary, especially when his officers have been found breaking the law.

“The community has a right to hold their officers to very high standards,” Deane said. “We can’t expect them to have confidence in us, to trust us, to report crimes to us, without us being honorable people.”

Deane has always told it like it is, getting out in front of crime trends and discussing them openly, even questioning his bosses, as he did in the immigration debate.

Corey Stewart, chairman of the county board, said he was frustrated by Deane’s objections to the county’s policy and believed that it was daunting to have someone from inside the county’s bureaucracy taking him on. The board later changed its policy, which now conforms with Deane’s vision.

“At the time, I saw him as an adversary,” Stewart said. “But I look back on it now, and I realize he was right.”

Deane said he has always taken a special interest in crimes against children, which is why the 2009 case of Lexie Glover bothered him so. Lexie was reported missing, but she was later discovered dead and her mother was charged with killing her. Deane said the police department and other county agencies missed signs of problems within the family.

After Lexie’s death, Deane instituted new policies and procedures for looking at child-abuse cases. It’s an “early warning system” designed to catch problems before they become critical.

Chuck Wexler, executive director of the Washington-based Police Executive Research Forum, for which Deane has served as vice president, said that Deane stands out nationally.

“The way Charlie handled the immigration issue and worked through it was a defining moment,” Wexler said. “It put Prince William County on the map in a good way, in terms of how you handle something as controversial as that.”

Deane said he hopes that the county board fills the chief’s job internally. Deane declined to discuss potential successors, but obvious contenders would be Deputy Chief Barry Barnard and Assistant Chiefs Mike Crosbie, Steve Hudson and Jay Lanham.

Stewart said that the board will conduct a national search for the next chief and added that it will be difficult to replace Deane. “The professionalism and integrity of the police department . . . is in large part due to him, and it’s going to be very hard to fill those shoes.”

Jeremy Borden contributed to this report.