SEOUL, South Korea — President Moon Jae-in of South Korea warned on Wednesday that North Korea would face stiffer sanctions if it resumed weapons tests, while crediting President Trump with helping force the North to resume dialogue and strike a broader agreement to improve Korean ties.

“I am giving a lot of credit to President Trump,” Mr. Moon said at a nationally televised news conference a day after the two Koreas forged their agreement during border talks. “I am expressing my gratitude.”

The White House said that Mr. Trump and Mr. Moon had spoken and “underscored the importance of continuing the maximum pressure campaign against North Korea,” adding that Mr. Trump “expressed his openness to holding talks between the United States and North Korea at the appropriate time, under the right circumstances.”

Mr. Moon’s comments and his conversation with Mr. Trump suggested a tactful maneuver by the South Korean leader to stroke the ego of Mr. Trump, who has claimed credit for the inter-Korean dialogue, while easing fears in Washington and among his conservative critics at home that in his eagerness for dialogue, he may be too accommodating to North Korea’s leader, Kim Jong-un.