WASHINGTON — President Trump defended on Wednesday his decision to disregard the advice of his national security team and congratulate President Vladimir V. Putin of Russia on his re-election, lashing out at the news media for reporting on how he diverged from his script and attacking his predecessors for failing to improve relations with Moscow.

Mr. Trump, enraged after officials leaked the contents of confidential notes he was given for the private phone call on Tuesday that exhorted him “DO NOT CONGRATULATE” Mr. Putin, argued in a pair of tweets on Wednesday afternoon that the conversation was part of his effort to foster better relations with Russia. He said such engagement could help the United States confront a host of national security challenges.

“I called President Putin of Russia to congratulate him on his election victory (in past, Obama called him also),” Mr. Trump wrote on Twitter, referring to President Barack Obama’s call to Mr. Putin in 2012. “The Fake News Media is crazed because they wanted me to excoriate him. They are wrong!”

But Mr. Trump’s handling of the call and his defense of it also pointed up his aversion to confronting Mr. Putin about Moscow’s misdeeds, which has become a theme of his presidency even as a special counsel investigates Russia’s efforts to sway the 2016 election in his favor.