Fairfax County Sheriff Stan Barry said Tuesday that he will retire in July, ending a career of more than three decades with the office that runs the jail and provides courthouse security.

Barry, a Democrat who has won election four times, cited personal reasons for stepping down. He oversees a staff of more than 600 and was first elected in 1999 after a 19-year career with the office. He became a deputy at 21.

“It’s been tremendous for me,” Barry said. “I could never have imagined my career would turn out this way. I thought this would be a fun job for a couple of years. I never thought it would go this far.”

County Board Supervisor Jeff C. McKay (D-Lee), who is a reserve sheriff’s deputy, credited Barry with a low-key competency that put the emphasis on the office instead of the man running it. He said Barry had saved the county millions of dollars by starting a work program that allows nonviolent offenders to do landscaping on county properties.

“He has done a phenomenal job as sheriff,” McKay said. “He is well-respected in law enforcement circles and by rank-and-file officers.”

Barry, the son of a former Republican state senator, survived some bruising campaigns during his years in office. During Barry’s most recent run, a GOP opponent said the sheriff could unfairly collect as much as $1 million in pension benefits. Barry challenged the allegation.

Fairfax County Circuit Court Judge Dennis J. Smith is expected to name an interim sheriff as a replacement in coming weeks, Barry said. A special election to name Barry’s successor will be held during the general election in November.