Virginia Gov. Terry McAuliffe (D) with Hillary Clinton in Alexandria in October 2015. (Melina Mara/The Washington Post)

Virginia was supposed to have been a battleground.

Yet for months, Democrat Hillary Clinton has had a comfortable lead in a state that, until Barack Obama came along, had not picked a Democrat for president since Lyndon Johnson.

Her prospects here seemed only to improve this week as Donald Trump’s Virginia campaign plunged into disarray less than a month before Election Day. It ousted its state co-chairman, who then publicly declared the campaign had been starved for resources and was pulling out of Virginia.

Trump’s campaign insisted that it was only moving some Virginia staffers to North Carolina for early voting and would return to fight for the commonwealth’s 13 electoral votes.

But to many observers — including some Republican insiders blindsided by the staffing shift — the battle was over.

Donald Trump’s presidential campaign fired its Virginia state co-chairman, Corey Stewart, on Oct. 10 after he took part in a protest in front of Republican National Committee headquarters. The protest drew dozens of Trump supporters. (WUSA)

“We got so far ahead here that we are no longer considered a swing state in Clinton World,” Gov. Terry McAuliffe told The Washington Post in an interview last week — before the release of a tape of Trump bragging about groping women.

Several factors appear to have pushed Virginia into the Clinton column: changing demographics that favor Democrats in statewide elections; divisions within the state Republican Party over Trump; Clinton’s selection of Sen. Tim Kaine, a well-liked former Virginia governor. as her running mate; and vigorous support from Gov. Terry McAuliffe (D), a close Clinton friend.

But even though most insiders expect Clinton to win next month, it doesn’t mean Virginia has turned blue.

“Even if Trump falls short in 2016 in Virginia, the Republicans are in a pretty good position for the next governor’s race,” said Stephen Farnsworth, a political-science professor at the University of Mary Washington. “To think Virginia is on its way to becoming the next Maryland is preposterous.”

The Virginia General Assembly remains firmly in GOP hands, and the Democrats who won statewide races recently had to fought hard to defeat their Republican opponents, including McAuliffe’s narrow win in the 2013 governor’s race and Sen. Mark R. Warner’s squeaker reelection in 2014.

Corey Stewart, who was fired as Virginia co-chair by the Trump campaign on Tuesday, said that Virginia would still be winnable if the Republican National Committee would provide resources to match grass-roots enthusiasm.

“It’s still not too late,” Stewart said.

But Clinton has had a lot of things going for her in Virginia, much of it due to McAuliffe.

When an ad for Trump flashed across McAuliffe’s TV screen recently, the 72nd governor of Virginia was immediately on the phone with Clinton’s campaign manager.

“Hey,” McAuliffe told Robby Mook, “I just saw a commercial.”

Trump had not advertised in the state since about Labor Day. If the Republican was back on the air, could that mean the state was back in play?

Mook reassured him that the Trump ad was part of a national buy, he said. The commonwealth — a critical but still-swingy piece of the electoral map — was still looking good for Clinton.

“We watch it very carefully,” McAuliffe said in an interview last week.

While juggling the demands of his day job, McAuliffe is “in constant communication” with the managers of Clinton’s national and Virginia campaigns, digging into data on door knocks as well as big-picture strategy and messaging. He talks with Clinton’s husband, former president Bill Clinton, nearly daily and with the candidate herself every week or two.

The governor helped Hillary Clinton assemble her campaign team, with some top veterans from his 2013 gubernatorial race, including Mook, who was McAuliffe’s campaign manager, and Brian Zuzenak, the former director of his political action committee, who leads Clinton’s Virginia campaign. McAuliffe also laid the foundation for her Virginia ground game with data investments in the state party.

He played a key role in Kaine’s selection — something McAuliffe says will greatly improve the likelihood of Democrats holding the governor’s mansion next year.

“I want to make sure we win Virginia,” McAuliffe said. “I trust Robby. I trust Brian. If they tell us we’re significantly ahead, we’re in good shape. I rely on that. So I’m not, like, second-guessing them. But I’m very closely monitoring to make sure there is not any movement for Trump. It’s very important for me that we win the state, obviously, for Hillary.”

The state’s potential to swing is one reason McAuliffe “lobbied very aggressively” for Kaine, though he also said the former governor was the best person for the job. If Kaine becomes vice president, McAuliffe will pick a replacement who, to keep the seat, would have to stand for election in 2017, when Virginia also chooses its next governor.

With a Clinton win in sight, many political observers are already looking past Election Day to focus on the likely Senate race and the 2017 gubernatorial contest.

Having a Senate contest on the ballot would motivate more voters to turn out for the off-year governor’s race, McAuliffe said, particularly in deep-blue, Washington-oriented Northern Virginia.

“As you know in the off years, we have a tough time getting those federal voters out,” he said. “So think of this: The only race in America for the Senate will be in Virginia.”

McAuliffe said none of his work for Clinton has interfered with his duties as Virginia’s chief executive.

Over the course of one 15-hour workday last week, he zipped from hurricane briefing to cybersecurity conference to economic-development pitch. On either end of that marathon, he squeezed in work for Clinton: an early-morning interview on CNN praising Kaine’s debate performance and a round of calls about the campaign late that night.

“Listen, when I got elected, I know some people thought I’d be like campaigner in chief,” McAuliffe said. “I do the job as governor very seriously. This is a very serious job. Every day, you meet new challenges. There’s always something going on.”

McAuliffe’s personal and professional life has been intertwined with the Clintons for more than 30 years, having served as their prolific and sometimes controversial fundraiser, as chairman of Hillary Clinton’s 2008 campaign and as Bill Clinton’s golfing buddy and “first friend.”

“It’s a reputational issue,” said Bob Holsworth, a former Virginia Commonwealth University political scientist.“He certainly sees elections as part of his legacy.”

McAuliffe will take a “significant political hit,” Holsworth said, if Clinton does not carry Virginia.

Just what and how much McAuliffe is doing for Clinton is sensitive for McAuliffe, who unlike his predecessors has never routinely released his political schedule. Do too much and Republicans will say he’s neglecting the state. Do too little and Democrats will warn he risks losing the White House.

“I spend 99 percent of my time being governor,” said McAuliffe, who registered a 53 percent approval rating in a recent University of Mary Washington poll. “If I’m doing a good job as governor, I think that reflects very well on Hillary. She believes that. And in fairness — take Hillary out of it — she wants me to be successful. Forget her presidential race. I mean, when I won, it was a big deal for the both of them, as you know. I mean, they were really, really excited. . . . I think we’ve got a good balance here. I’m not the campaigner in chief. I’m the governor.”

McAuliffe said that he would devote more time to Clinton if needed but that things were looking good. “It’s amazing I’m sitting here telling you this,” he said, “but we’re in very good shape in Virginia.”

Paul Schwartzman contributed to this report