Boris Johnson and Jeremy Corbyn have clashed over which of them is best placed to safeguard the NHS if they win the general election, with the Labour leader accusing the prime minister of being ready to sell it off to US corporations.

In a testy live debate on ITV, during which the prime minister repeatedly returned to the claim that he would “get Brexit done”, both men lavished praise on the NHS, but Corbyn said Johnson would put it up for sale.

Throughout the debate, Johnson continually tried to bring the focus back to Brexit, on which Corbyn repeatedly declined to say how he would campaign in a second EU referendum, while the Labour leader attacked the prime minister over the NHS and public services.

General election leaders' debate: who won? Read more

At one point, the audience openly laughed at Johnson when he agreed that the truth mattered in the election. The Conservatives came under fire during the debate when it rebranded its CCHQ Twitter account as “factcheckUK” and used it to pump out a series of pro-Tory messages.

As both parties tried to seize the initiative over the NHS, Corbyn at one point brandished a document he claimed showed that US negotiators hoped to secure full access to Britain’s health sector as part of a bilateral trade deal after Brexit.

“Full market access for US products to our National Health Service. You’re going to sell our National Health Service to the United States and big pharma,” he accused Johnson.

Johnson replied: “This is an absolute invention. It is completely untrue. Under no circumstances whatever will this government, or any Conservative government, put the NHS on the table in any trade negotiation. Our NHS will never be for sale.

“We will continue to fund the NHS massively, as we are. We can only do so because we have a strong and dynamic economy.” And he sought to suggest that Labour’s radical reforms to the economy would wreck the public finances.

“What could be more ruinous for the NHS than a crackpot plan for a four-day week,” he said, referring to the aim of the shadow chancellor, John McDonnell, to reduce working hours across the economy over the next decade.

Play Video 1:20 'I wasn't impressed': party leaders react to ITV election debate – video

Corbyn also picked up Johnson for repeating the heavily disputed claim that the government was “building 40 new hospitals”.

The Labour leader said the Tory plans affected only six existing hospitals. Johnson rejected this, but added: “Yes, it is true, we are starting with six, but the seed funding has gone in for 40 new hospitals.”

How plausible are Johnson and Corbyn's election claims? Read more

Johnson repeatedly returned to Brexit throughout the hour-long debate, stressing that all 635 of his party’s candidates supported his withdrawal agreement and promising to leave the EU by the end of January.

Corbyn challenged Johnson’s timetable, arguing that it would take much longer to negotiate a free trade agreement with the EU. “You’re not going to get it done in a few months, and you know that perfectly well,” he said.

In return, the prime minister repeatedly asked Corbyn to answer the question of whether he would support a Brexit deal.

Labour’s policy is to negotiate a new deal with the EU27 within three months of taking office and put it to the public in a referendum within six months, along with the option to remain in the EU.

Corbyn firmly declined to say which side he would take in that referendum, instead insisting he wanted to bring the country together and would abide by whatever decision voters made.

At one point, as he insisted his position was clear, mocking laughter rippled through the audience. And Johnson said in his closing statement that if the Labour leader could not answer the question of which side he would campaign on, “I don’t think he’s fit to lead our country”.

But Johnson provoked laughter from the audience himself when he was asked by the debate’s host, Julie Etchingham:” “Does the truth matter in this election?” and he replied: “Yes, I think it does.”

Play Video 0:47 Johnson and Corbyn shake hands as they pledge to improve politics – video

Afterwards, senior Tory and Labour figures did battle in the spin room over who won the debate, claiming the audience was laughing loudest at their political opponents.

The cabinet minister Michael Gove repeatedly mocked Corbyn’s plans for a four-day working week and claimed the Labour leader would soon be out of a job. “It is the case that Jeremy Corbyn’s position on the four-day week inspired laughter and his position on Brexit inspired laughter,” he said.

Johnson and Corbyn fail to land blows in second-rate light entertainment | John Crace Read more

Barry Gardiner, a shadow cabinet minister, emphasised the audience scorn for Johnson’s truthfulness, saying: “People looked at the prime minister and thought: how can we believe a word he said? How can we believe the manifesto when it comes out? He promised we would come out on 31 October and he would die in a ditch if we didn’t. It’s just lie after lie after lie.”

During what was styled as a “quickfire round” of questions from viewers, the duo were first asked if the monarchy was “fit for purpose”. Corbyn responded: “It needs a bit of improvement,” bringing some cheers from the audience. Johnson said: “The institution of the monarchy is beyond reproach.”

Asked the same question about Prince Andrew, in the wake of his BBC interview about his links to the convicted child sex offender Jeffrey Epstein, Corbyn said: “Before we discuss Prince Andrew, I think we should discuss the victims that were there because of what Epstein was doing. I think there are very, very serious questions that must be answered, and nobody should be above the law, but the primary position ought to be the proper treatment of those people who were victims of this most appalling behaviour by Jeffrey Epstein and many others.”

Johnson said, more briefly: “I think all our sympathies should be, obviously, with the victims of Jeffrey Epstein, and the law must certainly take its course.”

With election day just over three weeks away, and the Conservatives maintaining a double-digit lead in most national polls, Corbyn hoped the debate would help him to close the gap.

In his closing statement, he urged the public to register to vote and said: “I ask that you vote for hope, and vote for Labour, on 12 December.”

Asked by an audience member what non-political Christmas present they would leave under the tree for each other, Jeremy Corbyn said he would give the prime minister a copy of Charles Dickens’ A Christmas Carol. Johnson initially said he would give the Labour leader a copy of his Brexit deal but, urged to set politics aside, he suggested a pot of damson jam.