WASHINGTON — President Trump hired Rudolph W. Giuliani to speak for him. But no less than Mr. Trump’s wife and his chief diplomat spent Thursday explaining that Mr. Giuliani does not always know what he is talking about.

Melania Trump, the first lady, let it be known that Mr. Giuliani has no idea how she feels about Stephanie Clifford, the pornographic film actress who goes by the name Stormy Daniels and says she had a sexual encounter with Mr. Trump, while Mike Pompeo, the secretary of state, made clear that Mr. Giuliani has nothing to do with North Korea policy. Their pushback came in response to the latest in a series of seemingly off-script moments by Mr. Giuliani, the former New York mayor who has joined the legal team representing Mr. Trump in the special counsel’s investigations into his campaign and associates.

Mr. Giuliani has been something of a loose cannon, making public comments that surprised other advisers, were later contradicted or touched on matters beyond his ostensible mandate. At a conference in Israel this week, Mr. Giuliani said Mrs. Trump accepted her husband’s denial that he had any sexual liaisons with Ms. Clifford. “She believes her husband and she knows it’s untrue,” Mr. Giuliani said.

That drew a sharp retort from the first lady’s office. “I don’t believe Mrs. Trump has ever discussed her thoughts on anything with Mr. Giuliani,” the first lady’s spokeswoman, Stephanie Grisham, said in an email to The New York Times.