Former governor L. Douglas Wilder on Thursday gave his coveted endorsement to Terry McAuliffe, the Democrat running for governor.

Wilder is a Democrat but also something of a political maverick, having bucked his party on occasion. He withheld his nod from state Sen. R. Creigh Deeds (D-Bath) in the governor’s race four years ago.

He had been publicly uncertain about whether he would back McAuliffe, a former national party chairman, prolific fundraiser and Clinton intimate who has never held elective office.

In May, Wilder told The Washington Post that McAuliffe “has got to get gravitas.” Just last month, after McAuliffe and his Republican rival, Attorney General Ken Cuccinelli II, spoke to the class Wilder teaches at Virginia Commonwealth University in Richmond, the former governor said he was waiting for one of the candidates to put “more meat on the bone.”

Wilder told The Post on Thursday that the federal government shutdown and the polarized Washington politics behind it have helped convince him that McAuliffe is the right man to lead Virginia.

“The thing that’s going on at the national level — we’re so close to it — we could show that we are not affected by it and we are going to move forward,” Wilder said. “We are not going to separate into enclaves — this group, that group. It’s not a matter of pitting one group against the other group.”

McAuliffe has positioned himself in the race as a bipartisan deal maker who would focus on jobs and the economy as governor. Cuccinelli has stressed those issues as well, but McAuliffe has highlighted the Republican’s past fights against abortion, gay rights and a university climate scientist to suggest that he would make those issues priorities as governor.

“I am honored to have the support of Governor Doug Wilder,” McAuliffe said in a statement. “Governor Wilder has a long record of responsible budgeting and working with members of both parties to get things done, exactly the opposite of what we are seeing happen in Washington, where Ted Cruz and Ken Cuccinelli’s extreme Tea Party allies have held the government hostage to drive their extreme ideological agenda. As governor, I will work in a bipartisan way to focus on growing and diversifying the Commonwealth’s economy and creating more opportunities for all Virginians.”

Cuccinelli has opposed the government shutdown. But McAuliffe has sought to tie the attorney general to it because, like Cruz, a Republican senator from Texas and leading figure in the shutdown drama, Cuccinelli has long been a favorite of the tea party.

Wilder’s endorsement follows a string of polls showing McAuliffe leading Cuccinelli.

Wilder declined to comment on the attorney general, who has said he voted for Wilder, once served as his intern and has met periodically with well before his current campaign. When asked what he meant about “pitting one group against the other,” Wilder said:

“Let’s be blunt — the perception with women, and one of the concerns, one of the reasons I was elected governor of Virginia, was a lot of the women of Virginia supported my candidacy because they felt that I understood and was attuned to their issues, among other people’s. I don’t want them to think that I’m not still not that person who was attuned to their issues.”

Wilder was scheduled to meet privately with McAuliffe at 1 p.m. Thursday to give him his endorsement.

In 1990, Wilder became the first African American governor of a state since Reconstruction. Although he left the governor’s mansion nearly 20 years ago, his endorsement was highly sought in this race as in others.