WASHINGTON — Libertarian presidential nominee Gary Johnson and his running mate, Bill Weld, came out swinging Wednesday against their major party rivals: Donald Trump and Hillary Clinton.

At a CNN town hall hosted by Anderson Cooper, Weld outright mocked Trump — saying he has “a screw loose” — while Johnson shed his typical reluctance to attack Clinton by questioning her integrity.

Still, the former governors sought to pull themselves from the fringe of the political spectrum to its center, pledging a less polarized political process if they were elected.

Attempting to pull themselves from the fringe of the political spectrum to its center, Libertarian presidential nominee Gary Johnson and his running mate, Bill Weld, on Wednesday pledged a less polarized political process if they were elected.

“If either Trump or Clinton are elected, things will be more polarized than ever,” Johnson said at a CNN town hall, adding that his role was “calling out both sides.”

Johnson’s stated goal is to raise his profile enough to secure an invitation to the presidential debates with Trump and Clinton. To do this, he needs to reach an average of at least 15% support in national polls.

So far, he has generally reached between 6%-13% support nationally, with the latest CNN/ORC poll finding him at 9% and a Fox News poll released Wednesday showing Johnson at 12% support nationally in a three-way race against Trump and Clinton.

Trump: ‘A screw loose’

Johnson and Weld have never been shy about attacking Trump, and the opening minutes of the town hall were no exception.

“He’s a showman. He’s a pied piper. He’s the music man,” Weld said of Trump. “More recently, it’s gotten more serious, and the noun that comes to my mind is a ‘screw loose.’ ”

Weld added that he thought Trump “should consider some other line of work, like anything other than president of the United States.”

Johnson piled on after Weld’s quip, calling Trump’s proposals on immigration and counter-terrorism immoral.

The presidential candidate also took issue with Trump’s slogan, “Make America Great Again.”

“I don’t think America has ever been better,” Johnson said.

Clinton as ‘pay-to-play’ candidate

Pulling no punches on Clinton, Johnson questioned the Democratic nominee’s integrity by casting her as “beholden.”

“It’s just not coincidence, I don’t think, that Bill Clinton and Hillary both are making huge amounts of money with these speaking fees,” Johnson said.

Specifically, he argued there were conflicts of interest between the work of the Clinton Foundation and Clinton’s work at the State Department. He said her work at State “smacks of pay-to-play.”

He stopped short of saying he personally felt Clinton was untrustworthy, but when asked why so many did, he said, “I totally get it.”

The self-styled fiscal conservative appeared to feel much more comfortable attacking Clinton on the broadstrokes of her policies, particularly her acceptance speech at the Democratic National Convention, which he mentioned more than once.

“Was there anything that she didn’t promise to anyone in her acceptance speech?” Johnson asked.

For his part, Weld did not engage in Clinton bashing. He has said in the past that he considers both Clintons his friends, having known Hillary Clinton since they both worked on the Watergate impeachment inquiry against President Richard Nixon.

On BLM: ‘My head’s been in the sand’

In one of the strongest moments of the night, Shetamia Taylor, who was wounded during the Dallas police ambush last month, asked Johnson about the “Black Lives Matter” movement. Johnson offered a mea culpa and pledged to work now that he had gained a heightened sense of racial discrimination.

“My head’s been in the sand on this,” Johnson said. “I think we’ve all had our heads in the sand, and let’s wake up. This discrimination does exist.”

Weld also called black unemployment a “national emergency.”

LGBT rights and religious liberty

Ellis Jeter, now a Columbia University Student, spoke of how he lost his job and student housing at a private religious school after he was outed as gay, and he asked the governors what they believed the role of government should be to protect people’s civil liberties.

Weld pointed to his actions as governor of Massachusetts in the 1990s to expand basic protections for LGBT people.

But Johnson reiterated a stance he holds that is somewhat at odds with many Libertarians. He said he did not support laws that would, for example, allow a baker to refuse to sell a cake for a gay couple on religious grounds.

“I fear that under the guise of religious liberty, the LGBT community is being discriminated against,” Johnson said. “I don’t want to support discrimination in any form whatsoever.”

But on the matter of judicial appointments, Johnson and Weld demurred. Both said they did not want to put forward a litmus test for potential judges.

Marijuana

Hitting a topic very much within Johnson’s wheelhouse, the discussion turned briefly to the topic of marijuana. The Libertarian nominee is a former CEO of a legal cannabis company and has admitted to indulging in edible pot products in the recent past.

Diane Carlson, an undecided Republican voter, asked Johnson about medical cannabis products.

“What we need to do is de-schedule Marijuana as a Class 1 narcotic. There needs to be research and development on marijuana, and in no way are we supporting kids being able to use marijuana,” he said.

He didn’t appear to satisfy Carlson’s concerns about misinformation surrounding medicines containing chemicals found in marijuana.

“So much research and development needs to take place that hasn’t taken place,” Johnson said, also stressing that “marijuana products compete directly with legal prescription drugs.”

Sex work

The town hall touched on a lot of issues national candidates rarely address, none moreso than when Johnson faced the question of decriminalization of prostitution.

Breaking with the position of many social libertarians in favor of decriminalizing prostitution outright, Johnson said the matter should be decided state-by-state and seemed to imply Nevada’s decriminalization model was one to follow.

However, he also said that prostitution, as it is currently practiced is not a victimless crime.

“The victim is the prostitute,” Johnson said of criminal prostitution.