Ed Gillespie gives remarks at his election night party in Springfield, Va., on Nov. 4. (Kate Patterson/For The Washington Post)

When Republican Ed Gillespie decided to challenge the mighty Sen. Mark R. Warner (D), the odds looked so long that politicos figured he must be up to something else. Now that buzz is louder than ever.

“Most people thought he was running to get his name out to run for governor. If that’s what he was doing, he was damn successful,” former governor L. Douglas Wilder (D) said. “And whomever the Democrats put up, they’ll have a hell of a fight.”

Gillespie said he has no immediate plan to run for governor or anything else, but his dramatic near-win against Warner last week gave Virginia Republicans their greatest injection of optimism in four years. It positioned Gillespie as a badly needed leader of a fractured party. And it demonstrated that the commonwealth — after twice voting to send Barack Obama to the White House and last year giving Democrats a sweep of three statewide offices — can still spring whopping swing-state surprises.

“It’s given great hope to many conservatives for a very, very bright future,” said Pete Snyder, a Northern Virginia entrepreneur who lost the GOP nomination for lieutenant governor in a divisive convention last year. “I think there was conventional wisdom that Virginia was trending blue. It’s simply not the case. It’s as competitive as ever.”

Gillespie, a political operative and lobbyist making his first bid for elective office, came within one percentage point of toppling Warner, a former governor who for much of the past decade has been the state’s most popular politician. Warner won his first Senate term in 2008, defeating former governor James S. Gilmore III (R) in a 32-point landslide.

A blue Virginia tide turns red for 2014

“It made Warner look 10 feet tall,” said Gilmore, who attributed that lopsided result to “an abiding dislike of George W. Bush and excitement for Barack Obama” and concluded, “It’s now clear that Mark Warner is not invincible.”

Gillespie, a former Republican National Committee chairman, came to the race unknown to many ordinary Virginians despite his heft as a national political insider. A man who helped write congressional Republicans’ “Contract With America” in 1994, served as a counselor to President George W. Bush and created the super PAC American Crossroads with Karl Rove launched his campaign 30 points down and with name recognition near zero.

Even though Gillespie has vast political connections and control of the Senate was in play, big outside money never poured in for the Republican. Gillespie’s natural allies put their cash into races that appeared to be winnable. To many, the contest in Virginia was not one of those, even as polls showed the margin tightening to the high single digits in the campaign’s final month.

It was the same late-breaking saga a year earlier: Then-Attorney General Ken Cuccinelli II (R) was closing in on Terry McAuliffe (D) in the waning days of the governor’s race, but the funding that might have tipped the balance never materialized. Two back-to-back near misses could now convince GOP donors that, in Virginia’s volatile political climate, races can be worth the investment even when they appear to be out of reach.

“I know what it’s like to be closing late with your political allies not pitching in because they think the race looks unwinnable,” Cuccinelli said. “Virginia is a very competitive state that will obviously continue to serve up close races, including in 2016.”

Gillespie said he knew he was gaining on Warner as they neared the finish line. He could sense it in the big crowds he was drawing, feel it in their zeal. The only place he couldn’t see it was in internal polls: His cash-strapped campaign didn’t field any in the last two weeks, pouring what money it had into TV commercials.

Gillespie’s team made a calculated gamble late in the race to go up in the pricey ­Washington-area TV market before it could really afford to. The hope was that the ads would draw more attention to the race, prompting outside groups to jump in. They did not. And the ads had to be slashed in the last 10 days. “The [ad] buy was on life support,” said Phil Cox, a Gillespie adviser.

Yet Gillespie remained optimistic, telling cheering supporters on the eve of Election Day that “hard work beats big money every time, and we’re going to prove it tomorrow.”

In the end, Warner won. But the margin was so stunningly narrow — fewer than 17,000 votes out of more than 2 million cast — that Republicans widely consider the outcome a moral victory.

And that has thrust the Gillespie-for-something talk into overdrive. With everyone, it seems, but Gillespie himself. Governor in 2017? Senate in 2018? The current answer is no.

“There are a lot of really good people who I know are thinking about a future race, and I’m not one of them,” Gillespie said in an interview Friday after he conceded to Warner.

Even professionally, Gillespie said he was up in the air. His only immediate plan was to regroup with his wife, Cathy, and their three children. After his concession speech, the couple jumped on the highway to parents’ weekend at daughter Mollie’s college.

The race has made Gillespie and many others certain of one thing: He can be a force to help energize a state GOP beset by internal strife and demoralized by the implosion of its standard-bearer, former governor Robert F. McDonnell (R), amid scandal and a criminal conviction.

Republicans had been on a roll in Virginia, sweeping races for governor, lieutenant governor and attorney general in 2009, and grabbing three congressional seats from Democrats in the 2010 tea party wave. Then came a disastrous General Assembly bill in 2012 that would have required most women to undergo an invasive “transvaginal” ultrasound before an abortion. Lampooned by liberal commentators and even “Saturday Night Live,” the measure helped feed the Democrats’ “war on women” narrative going into the elections that year. Virginia voted to send Obama back to the White House and gave a U.S. Senate seat to former governor Timothy M. Kaine (D).

There was no clear consensus on how to pick up the pieces, with the tea party wing demanding to stay the course ideologically while establishment types were pleading for moderation. The party turned on itself, with the conservatives wresting control of state committees and scrapping an agreed-upon 2013 statewide gubernatorial primary for a convention. A convention tends to favor more conservative candidates such as Cuccinelli, whose supporters pushed for the change. That nominating method also produced a candidate for lieutenant governor, Chesapeake minister E.W. Jackson, who was wildly popular with grass-roots activists but controversial because of inflammatory statements on topics such as homosexuality and yoga-style meditation.

In the end, the conservatism of both Cuccinelli and Jackson was partly blamed for the year’s disastrous outcome — the loss of all three statewide seats on the ballot for the first time in 24 years.

There were signs that the strife had not abated this year. Tea party discontent rose up in a GOP primary in the Richmond suburbs as Dave Brat, an underfunded economics professor, unexpectedly toppled Rep. Eric Cantor , then the House majority leader.

But Gillespie managed to keep the party behind him. For months leading up to a nominating convention in Roanoke, he had reached out to party members of all stripes, acknowledging grass-roots activists’ suspicions of him as a longtime Washington insider but assuring them that their issues were his.

Just days before Cantor’s loss, Republicans quickly lined up behind Gillespie at the convention.

“The party is relatively united, which is something we haven’t always been lately,” former lieutenant governor John H. Hager (R) said. He called Gillespie’s strong showing “very cathartic.”

It was hardly a given that Gillespie would make a good candidate. No one doubted the communications skills of the former RNC chairman, veteran of countless TV appearances. But it’s one thing to make your points on“Meet the Press” and then retire to your home just across the Potomac River. It’s another to crisscross a state for a year on a budget so tight you have to bunk with supporters to save on hotels.

“The good ones make it look fun, and Ed made it look fun. He had fun,” adviser Tucker Martin said. He recalled how Gillespie, who stayed the night with Martin and his wife whenever he was in Richmond, once arrived after a long day on the trail with steaks, potatoes and asparagus.

“He got right in the kitchen and asked, ‘Where’s the butter and salt?’ ” Martin said. “This is the first candidate who’s ever cooked me dinner. He really enjoyed it, and voters could pick up on how positive he was and how optimistic he was. . . . He’s been everybody’s senior adviser, and this was his opportunity to be the candidate. And it turned out he was excellent at it.”

Gillespie said he took to heart advice that Phil Gramm, the former U.S. senator from Texas, offered during an early fundraising call. “He said, ‘You’re going to be the Republican nominee for the United States Senate from the great commonwealth of Virginia. Think how many people get to say that. You should love every minute of it,’ ” Gillespie recalled.

Gillespie said he did just that, even while logging 56,000 miles over 10 months in a Jeep Grand Cherokee or RV. He had been all over Virginia before, as onetime head of the state Republican Party and as chairman of McDonnell’s 2009 gubernatorial campaign. But this was his first time soaking it all up as the candidate. And he couldn’t get enough of it.

“I can’t tell you how much I enjoyed going into the mines, and going out to the apple orchards and talking to voters,” he said. “Just traveling Virginia — I’ve been all around it, but everywhere you go is gorgeous. I feel bad for candidates that have to run in states that aren’t Virginia.”

Jenna Portnoy contributed to this report.