Sen. David Vitter (R-La.) speaks on Oct. 6 during a news conference on dangerous chemicals. (Mark Wilson/Getty Images)

Six months ago, Sen. David Vitter was a heavy favorite to be Louisiana’s next governor. He was the best known of the four major candidates, had more money than all the others combined and could count on a conservative Republican base in a deep-red state.

But now, just days before Saturday’s primary, Vitter is in a dogfight — weighed down by the resurrection of a past sex scandal, his 16 years in gridlocked Washington and voters’ dismay with the outgoing governor, Bobby Jindal (R).

Vitter appears positioned to place second in a “jungle primary” where the top two finishers advance to a runoff, regardless of party. The big surprise is that Vitter is trailing the Democratic candidate, state Rep. John Bel Edwards, in a theoretical head-to-head matchup by 10 to 20 points.

“If he makes the runoff, it’s a toss-up,” said Verne Kennedy, who is polling the race for an independent group of businesspeople.

No one who has studied Louisiana politics is dismissing Vitter. He won reelection in 2010 by tying his Democratic opponent to President Obama. The Republican Governors Association has already begun airing TV ads tying Edwards to Obama, who lost Louisiana by 17 points in 2012.

Sen. David Vitter (R-La.) speaks to the media with his wife, Wendy, in Metairie, La., on July 16, 2007, apologizing after his telephone number appeared in the phone records of the “D.C. Madam.” (Alex Brandon/AP)

Vitter also got a boost in Washington this week when Senate Majority Leader Mitch McConnell (R-Ky.) allowed a show vote on legislation sponsored by Vitter to cut off federal funding for “sanctuary cities,” which do not notify the federal government when illegal immigrants are arrested for minor offenses.

Vitter always runs as an outsider, championing his rejection of the go-along-to-get-along philosophy, and his political sustenance comes from social conservatives. In the race for governor, he has an A-plus rating from the National Rifle Association, has been endorsed by the National Right to Life organization and has a track record of opposing Obama at every turn.

But since July, Vitter has stalled in the polls while his negative ratings are meeting or exceeding his positives. Over the same period, Edwards has consolidated support among his Democratic base and surged ahead in polls.

Two other Republicans — Lt. Gov. Jay Dardenne and Scott Angelle, an elected member of the Public Services Commission, which regulates utilities — have faced unrelenting attack ads from Vitter. Neither is likely to edge past him to make the Nov. 21 runoff with Edwards.

Vitter’s problems begin with a story broken by Hustler magazine in 2007: The senator’s name appeared in call logs of the “D.C. Madam” in 1999 and 2000, when he was a freshman House member. He made several of the calls from the House floor, records showed. In the days to come, a prostitute and a notorious madam in New Orleans came forward to claim him as a client.

The senator had always portrayed himself as a strong supporter of family values and a scourge of immoral politicians. In a three-minute statement delivered with his wife, Wendy, at his side, Vitter apologized to the public and said he had sought and won forgiveness from God and Wendy. He left the event without answering any questions.

State Rep. John Bel Edwards (D), left, and Sen. David Vitter (R) take their places before a Louisiana gubernatorial debate on Oct. 1 in New Orleans. (Gerald Herbert/AP)

Vitter was never charged, and a congressional panel cleared him of wrongdoing. But this year, as he has pursued his gubernatorial bid, a Baton Rouge law firm has spent $1.6 million to broadcast television ads — using video clips and shots of sensational headlines — to remind voters of the scandal.

The trial lawyers behind the ads want to defeat Vitter because he has promised to kill lawsuits filed by the firm that accuse oil and gas companies of polluting land and aquifers throughout the state, as well as destroying coastal wetlands.

On a recent evening, one of the ads aired on a local news channel showing a woman saying Louisiana couldn’t have a governor “with so many dark secrets.” It was immediately followed by a Vitter campaign spot featuring his wife. “I know David Vitter better than anyone,” she says, “and I can tell you he’ll make a great governor.”

Meanwhile, Edwards, the small-town son of a rural sheriff, touts his background as a West Point cadet and an Army Ranger who likes to hunt and opposes abortion — all part of a strategy to win back conservative whites lost to Republicans in recent years.

He has also appealed to left-of-center Democrats by calling for an increase in the minimum wage, promising to approve an expansion of Medicaid in the state and highlighting his vociferous opposition to Jindal as the leader of the Democratic minority in the state House.

“David Vitter would be Bobby Jindal on steroids,” he said in an interview.

Edwards and Vitter’s two Republican rivals complain that Vitter appears only before friendly audiences and has ducked most of the TV debates to avoid questions about the prostitution scandal.

Following a debate last week, Vitter was the only candidate who didn’t meet with the media afterward. His spokesman said later that the senator had instead gone to eat dinner and watch a New Orleans Saints game on television.

During the other debate where he appeared, Vitter portrayed himself as the true conservative in the race and attacked his three opponents.

Angelle responded by dubbing him “Senator Pinocchio,” adding that Vitter has “not only been wrong on fornication, he’s been wrong on taxation and he’s been wrong on education.”

Vitter skipped the Cattle Festival parade this month in Abbeville, a town in the Acadiana region of southwest Louisiana. One of the many weekend festivals traditionally frequented by candidates, it offered a barn dance, a trail ride and a “fais do-do” dance party with zydeco and Cajun music.

Edwards and Angelle came to ride in the parade. Afterward, one voter asked Edwards whether he was related to Edwin Edwards, the wily Cajun who served a record four terms as governor but also spent nearly a decade in prison on corruption charges.

“I am, if you really like him,” Edwards replied. (They are not related.)

Before the parade, Mike Simon, a retired firefighter, said he would vote for Vitter. “He knows how screwed up Washington is,” Simon said underneath a tentlike canopy on a hot and humid afternoon. “Maybe he can un-screw-up things here.”

A few yards away, Eddie McKenzie, a retired policeman, said Vitter’s prostitution scandal didn’t bother him. “Everybody’s got skeletons,” he said.

But Ruth Boudreaux, a retired school bus driver, held a different view. “The cheating scandal bothers me,” she said. “It was pitiful that his wife had to stand alongside him.”

Bridges is a freelance writer. Alice Crites contributed to this report.