“This is an emotional time and we all need to think through these issues with a care that recognizes the need for change but also respects the complicated history of the Civil War,” Mr. Webb said in a statement at the time, standing in contrast to both Republicans and Democrats who said the flag was an outdated symbol that needed to be retired.

But Mr. Webb does bring a diverse background that could appeal to Democratic voters looking for a candidate who is more than a career politician. He has written 10 books, including several war novels. He is also an accomplished journalist. In 1983 he won an Emmy award for a report he produced on the Lebanese civil war for “The MacNeil/Lehrer NewsHour.”

After graduating from the United States Naval Academy in 1968, he served as a rifle platoon and company commander in Vietnam and was awarded the Navy Cross, the Silver Star Medal, two Bronze Star Medals and two Purple Hearts.

After working in Congress in veterans affairs, he rose through the ranks of the Defense Department and in 1987 was appointed secretary of the Navy under President Ronald Reagan.

Mr. Webb served in the Senate from 2007 to 2013. He made veterans issues a priority and remained focused on foreign affairs, making a high-profile trip to Myanmar in 2009 to help secure the release of an American prisoner, and serving as chairman of the Foreign Relations Committee’s Asia-Pacific subcommittee. On domestic affairs, Mr. Webb was a strong proponent of reforming the criminal justice system, an issue that is again in the limelight.

But it was his consistent and vocal opposition to the Iraq war that served as a centerpiece of his announcement Thursday, and it is an issue that he will likely focus on in trying to contrast himself to Mrs. Clinton, particularly with his military credentials.

“Let me assure you, as president I would not have urged an invasion of Iraq, nor as a senator would I have voted to authorize it,” Mr. Webb said in his announcement. “I warned in writing five months before that invasion that we do not belong as an occupying power in that part of the world, and that this invasion would be a strategic blunder of historic proportions, empowering Iran and in the long run China, unleashing sectarian violence inside Iraq and turning our troops into terrorist targets.”