President Donald Trump has said he had nothing to do with directing the US navy to keep a warship named after the late senator John McCain out of sight during his visit to Japan this week.

Speaking to reporters as he left the White House, Mr Trump acknowledged that he “was not a big fan” of the late senator “in any way, shape or form”, but said: “I would never do a thing like that.”

“Now, somebody did it because they thought I didn’t like him, OK? And they were well-meaning, I will say,” he added, while insisting he was kept in the dark.

I was not informed about anything having to do with the Navy Ship USS John S. McCain during my recent visit to Japan. Nevertheless, @FLOTUS and I loved being with our great Military Men and Women - what a spectacular job they do!

Three US officials confirmed to the Associated Press that the White House told the US navy to keep the warship named after Mr McCain, with whom Mr Trump long feuded, out of Mr Trump’s sight during the president’s visit to a base outside of Tokyo on Tuesday.

The Wall Street Journal reported that a US Indo-Pacific Command official wrote an email to navy and air force officials about Mr Trump’s visit to Japan over Memorial Day weekend.

It included instructions for preparations for the USS Wasp, the ship on which Mr Trump was to speak.

“USS John McCain needs to be out of sight,” according to the email, obtained by the Journal and whose existence was confirmed to the Associated Press by three US officials.

When a navy commander expressed surprise at the instruction, the US Indo-Pacific Command official answered, “First I heard of it as well,” the Journal reported.

The official said he would talk to the White House Military Office to get more information about the directive, the newspaper reported.

Late on Wednesday, Mr Trump tweeted that he “was not informed about anything having to do with the Navy Ship USS John S. McCain during my recent visit to Japan”.

Still, he added on Thursday that he “was very, very angry with McCain because he killed healthcare. I was not a big fan of John McCain in any way, shape or form”.

A Republican, Mr McCain broke with the president in key areas.

John McCain (John Stillwell/AP)

He incensed Mr Trump with his thumbs-down vote foiling the effort to repeal president Barack Obama’s healthcare law.

Mr Trump also mocked Mr McCain’s military service, which included years of imprisonment and torture during the Vietnam War.

The warship, commissioned in 1994, was originally named after the senator’s father and grandfather, both navy admirals named John Sidney McCain.

Last year, the navy rededicated the ship to honour the senator as well.

In Jakarta, Indonesia, on Thursday morning, acting US defence secretary Patrick Shanahan told reporters he had been unaware of the request.

Mr Shanahan said he would never dishonour the memory of a great American like Mr McCain or disrespect the young men and women in the crew of the ship.

“I never authorised, I never approved any action around the movement or activities regarding that ship,” Mr Shanahan said.

Acting US secretary of defence Patrick Shanahan (Dita Alangkara/AP)

He said the military “needs to do their job” and stay out of politics.

The Journal, citing photos it reviewed, reported that a tarpaulin was placed over the USS John S McCain’s name before Mr Trump’s arrival and that sailors were instructed to remove any coverings from the ship that included its name.

Asked if the tarpaulin was meant to block Mr Trump’s view of the ship, the officials said the tarpaulin had been placed on the ship for maintenance and removed for the visit.

US navy commander Clay Doss, spokesman for US 7th Fleet, told the AP that the tarpaulin was on the ship on Friday but was removed by Saturday morning, the day Mr Trump arrived.

“All ships remained in normal configuration during the president’s visit,” he said.

Two US officials told the AP that all the ships in the harbour were lined up for Mr Trump’s visit, and they were visible from the USS Wasp.

The officials said most of their names probably could not be seen since they were side by side but that the name of the USS John S McCain could be seen from the pier.

The name of USS John S. McCain was not obscured during the POTUS visit to Yokosuka on Memorial Day. The Navy is proud of that ship, its crew, its namesake and its heritage.

Rear Admiral Charlie Brown, navy public affairs officer, tweeted on Wednesday night: “The name of USS John S. McCain was not obscured during the POTUS visit to Yokosuka on Memorial Day. The Navy is proud of that ship, its crew, its namesake and its heritage.”

A paint barge was in front of the USS John S McCain on Saturday morning when 7th Fleet officials walked the pier to see how everything looked for the visit.

The barge was then ordered to be moved and was gone by the time Mr Trump arrived, the officials said.

The Journal reported that sailors on the USS John S McCain, who usually wear hats with the ship’s name on it, were given the day off when Mr Trump visited.

Two US officials told the AP that sailors on the USS John S McCain were not told to stay away but that many were away for the long weekend.

The officials also said that about 800 sailors from more than 20 ships and navy commands were on the USS Wasp during the president’s visit, and all wore the same navy hat that has no logo, rather than wearing individual ship or command hats.

Mr Trump was not welcome at Mr McCain’s funeral and raised the White House’s US flag back to full-mast shortly after Mr McCain’s death, despite US Flag Code stating that it should remain at half-mast for another day.

The flag returned to half-mast later in the day.

Trump is a child who will always be deeply threatened by the greatness of my dads incredible life. There is a lot of criticism of how much I speak about my dad, but nine months since he passed, Trump won't let him RIP. So I have to stand up for him.