WASHINGTON — President Trump revealed new details on Friday about the closely guarded medical condition of Melania Trump, the first lady, saying that she underwent a four-hour operation and that her recovery would keep her from traveling abroad with him.

In the weeks since aides said she underwent a procedure to treat a benign kidney condition, Mrs. Trump has directed her East Wing aides to release almost no information about her medical condition or explain why she was at Walter Reed National Military Medical Center for five days.

Until Mr. Trump stepped in front of the cameras on Friday as he departed on an international trip, there had been no leaks.

The president said that Mrs. Trump “wanted to go” with him to the Group of 7 summit meeting in Quebec, and then on to Singapore for a planned sit-down with Kim Jong-un, North Korea’s leader. But, the president said, Mrs. Trump was staying at the White House on doctor’s orders.