The two Virginia Democrats locked in a tight race for their party’s gubernatorial nomination were cordial in their final debate but offered competing visions for a swing state where Republicans control the legislature.

In a 30-minute debate televised Sunday, Lt. Gov. Ralph Northam touted his experience and relationships in Richmond, saying they make him the ideal choice to shepherd through pragmatic policies to help working families.

Former congressman Tom Perriello urged a more dramatic approach, saying the state’s next leader needs to champion an expansive progressive platform, complete with new social programs funded by tax increases on the wealthiest, even if it faces opposition from Republican lawmakers.

The debate, which was held Thursday but aired on NBC 4 Washington on Sunday, was the candidates’ fifth, and the last before the June 13 primary.

Northam stressed the importance of compromise and working with Republicans.

“We have to be very secure in what we believe in, but we have to be open-minded and listen to other ideas and agree to disagree,” he said. “But the Virginia way is, at the end of the day, we are going to do what’s in the best interest of Virginia.”

Throughout the debate, Perriello said that he is proposing what Virginians need, not what the political environment permits.

“I am sick and tired of hearing what’s possible and not possible,” Perriello said. “Leadership is about starting with what actually solves the problem. Leadership is about making tough choices. It’s about not accepting a ‘Virginia way’ that has choked too much of the kind of solutions we need for a new generation.”

While Northam, 57, and Perriello, 42, agree on a litany of issues, their campaign platforms differ in scope.

Northam wants tax credits to encourage businesses to offer paid family leave, a workforce development program and a tweak to the state’s grocery tax, which his campaign says would cost $67 million. At the debate, he suggested finding savings to fund his ideas with a top-down review of state agencies and decriminalization of simple possession of marijuana.

Both platforms are likely to face resistance from a legislature currently controlled by Republicans. Gov. Terry McAuliffe (D), who under the state constitution cannot serve consecutive terms, has focused much of his governorship on economic development, vetoes and executive orders he can take independent of the legislature.

Northam touted a 10-year relationship with Del. M. Kirkland Cox (R-Colonial Heights), who is set to be the speaker of the House of Delegates if Republicans maintain their control after the November general election. “I look forward to the relationships I already have in Richmond and continuing that process in the upcoming four years,” said Northam.

Perriello, who would be new to Richmond, said he would draw on his experiences as a State Department envoy to Africa and his work for an international war crimes court.

“If we can bring together sides that have literally been killing each other for years, I think we’ll find a way to bring people together in Richmond,” he said.

Both Democrats have strongly criticized President Trump as they seek to woo Democratic activists and independents fired up in opposition to his presidency.

Perriello ticked off different ways a governor can resist Trump and the GOP-controlled Congress, from refusing to cooperate with federal immigration authorities to rejecting a rollback of health-care protections allowed under the Trumpcare bill passed by House Republicans.

“Donald Trump’s issues are Virginia issues,” Perriello said. “We are going to stand as a firewall against that hate.”

Northam, who refers to Trump as “a narcissistic maniac” in one of his campaign commercials, also said he would stand up to the president. But he added that Virginia voters with whom he’s spoken are most focused on good jobs, health care and safe communities.

“There is a lot of attention from the national scene, but at the end of the day, this is about the governorship for the commonwealth of Virginia,” Northam said.

Asked if they would try to spare other immigrants from deportations by pardoning their criminal records, Northam said he would examine the situations on a case-by-case basis, while Perriello said he would “absolutely” look for similar cases.

Asked about their biggest mistakes in office, Northam said he didn’t have regrets and instead touted his work on passing a bill to ban smoking in restaurants. Perriello cited his vote for an un­successful amendment to the ­Affordable Care Act that would bar insurers covering abortions from receiving federal subsidies.

A Washington Post-Schar School poll released two weeks ago found the race for the Democratic nomination was neck-and-neck.

The Democratic primary winner will face the victor in the three-way Republican primary between front-runner and former political strategist Ed Gillespie, Prince William Board of County Supervisors Chairman Corey A. Stewart and state Sen. Frank W. Wagner of Virginia Beach.