There were no immediate details on the contents of the document but Trump said he expected the denuclearization process to start "very, very quickly.”
Although the breakthrough made at the summit marks just the start of a diplomatic process, it could bring lasting change to the security landscape of Northeast Asia, just as former US President Richard Nixon visit to Beijing in 1972 led to the transformation of China.
Before signing what Trump described as a "comprehensive letter", Kim said the two leaders had a historic meeting and “decided to leave the past behind. The world will see a major change.”
Trump said he had formed a "very special bond" with Kim and that relationship with North Korea would be very different.
"People are going to be very impressed and people are going to be very happy and we are going to take care of a very dangerous problem for the world," Trump said.
Asked whether he would invite Kim to the White House, Trump said: "Absolutely, I will."'
He called Kim "very smart" and a "very worthy, very hard negotiator."
"I learned he's a very talented man. I also learned that he loves his country very much."
During a post-lunch stroll through the gardens of the Singapore hotel where the summit was held, Trump said the summit had gone "better than anybody could have expected.”'
Kim stood silently alongside, but the North Korean leader had earlier described their meeting as "a good prelude to peace.”
Both men walked to Trump's bullet-proof limousine, nicknamed "The Beast", and looked in at the rear seat, with Trump apparently showing Kim something inside. They then resumed their walk.
They had appeared cautious and serious when they first arrived for the summit at the Capella hotel on Singapore's Sentosa, a resort island with luxury hotels, a casino, manmade beaches and a Universal Studios theme park.
But, with cameras of the world's press trained on them, they displayed an initial atmosphere of bonhomie as they met on the verandah of the Capella, a refurbished 19th century British regimental officers' mess.
After a handshake, they were soon smiling and holding each other by the arm, before Trump guided Kim to the library where they held a meeting with only their interpreters. Trump had said on Saturday he would know within a minute of meeting Kim whether he would reach a deal.
Inside, they sat alongside each other against a backdrop of North Korean and US flags, with Kim beaming broadly as the US president gave him a thumbs up.
The combatants of the 1950-53 Korean War are technically still at war, as the conflict, in which millions of people died, was concluded only with a truce.
After initial exchanges lasting around 40 minutes, Trump and Kim emerged, walking side-by-side through the colonnaded hotel before entering a meeting room, where they were joined by their most senior officials.
Kim was heard telling Trump through a translator: "I think the entire world is watching this moment. Many people in the world will think of this as a scene from a fantasy...science fiction movie."
Asked by a reporter how the meeting was going, Trump said: "Very good. Very, very good. Good relationship."
Kim also sounded positive about the prospects of peace.
"We overcame all kinds of skepticism and speculations about this summit and I believe that this is good for the peace," he said. "I believe this is a good prelude for peace."
The dollar jumped to a three-week top on Tuesday and Asian shares rose on the news.
Trump was joined by Secretary of State Mike Pompeo, National Security Adviser John Bolton, and John Kelly, White House Chief of Staff, for the expanded talks, while Kim's team included former military intelligence chief Kim Yong Chol, foreign minister Ri Yong Ho and Ri Su Yong, vice chairman of the ruling Workers' Party.
As the two leaders met, Singapore navy vessels, and air force Apache helicopters patrolled, while fighter jets and a Gulfstream 550 early warning aircraft circled.
Body language expert said both men tried to project command as they met, but also displayed signs of nerves.
After the meetings, the two teams and other senior officials met for a working lunch, where beef short ribs, sweet and sour pork and "Daegu Jormin", or Korean braised cod, were served for the main course, according to the menu. That was to be followed by dark chocolate tarts, pastries and vanilla ice cream for dessert. The North Korean leader's sister and close confidante Kim Yo Jong was among the lunch party.
As the cameras captured the moment, Trump quipped: "Very nice. Getting a good picture everyone, so we all look nice and handsome and thin...perfect."
In the hours before the summit began, Trump expressed optimism about prospects for the first-ever meeting of sitting US and North Korean leaders, while Pompeo injected a note of caution whether Kim would prove to be sincere about his willingness to denuclearize.
Pompeo said the summit should set the framework for "the hard work that will follow", insisting that North Korea had to move toward complete, verifiable and irreversible denuclearization.
North Korea, however, has shown little appetite for surrendering nuclear weapons it considers vital to the survival of Kim's dynastic rule.
Sanctions on North Korea would remain in place until that happened, Pompeo said on Monday. "If diplomacy does not move in the right direction ... those measures will increase."
The White House said later that discussions with North Korea had moved "more quickly than expected" and Trump would leave Singapore on Tuesday night after the summit, rather than Wednesday, as scheduled earlier.
Kim is due to leave on Tuesday afternoon, a source involved in the planning of his visit has said.
Trump spoke to Moon and Japan's Prime Minister Shinzo Abe, both key allies of Washington in the region, to discuss developments ahead of the summit.
"I too, got little sleep last night," Moon told his cabinet in Seoul as the summit began in Singapore.
"I truly hope it will be a successful summit that will open a new age for the two Koreas and the United States and bring us complete denuclearization and peace."