The two leaders, who arrived almost at the same time in this seaside city of Brazil last evening to attend the BRICS Summit, engaged shortly thereafter for what was described as "good discussions and good meeting".
The meeting - first between the two leaders - was scheduled for 40 minutes but it went on for 80 minutes as it was freewheeling discussion without any constraints.
"Had a very fruitful meeting with Chinese President Mr. Xi Jinping. We discussed a wide range of issues," Modi tweeted after the meeting with Xi, also the General Secretary of the ruling Communist Party of China.
"Both sides emphasised on the need to find a solution to the Boundary Question. The Prime Minister stressed the importance of strengthening mutual trust and confidence, and maintaining peace and tranquility on the border," said a statement issued by the Prime Minister's Office.
Prime Minister Modi told Xi that "if India and China could amicably resolve the Boundary Question, it would set an example for the entire world, on peaceful conflict resolution," the statement added.
The two sides have held 17 rounds of the Special Representative talks aimed at resolving the boundary issue.
India asserts that the border dispute covered nearly 4,057-km long Line of Actual Control, while China claims that it confined to about 2,000 km to the area of Arunachal Pradesh, which it refers as Southern Tibet.
During the meeting, Modi also suggested the addition of one more route for the Kailash-Mansarovar Yatra in Tibet, keeping in view the terrain difficulties.
President Xi "accepted this as a suggestion for consideration," the statement said.
The Yatra involves trekking at high altitudes of up to 19,500 feet under arduous conditions.
The leaders of the two fastest growing economies observed that India and China had enormous opportunities to not only forge mutually beneficial partnerships, but also serve as catalytic agents of Asian and global prosperity.
President Xi underscored the importance of the bilateral relationship and said: 'When India and China meet, the whole world watches.'
The two leaders expressed satisfaction at the high momentum of bilateral engagement during the past few weeks, including the visit of Vice President Hamid Ansari to China and the visit of Chinese Foreign Minister Wang Yi to India as President Xi's Special Envoy in June.
In a significant development, China invited India to attend a summit of Asia-Pacific Economic Cooperation (APEC) in November. APEC is a forum for 21 countries that seeks to promote free trade and economic cooperation throughout the Asia- Pacific region.
The surprise invitation for the APEC summit as part of partnership and engagement came in the context of the two leaders discussing the need for the two countries to work together in international fora like BRICS and other fora.
Xi also said India should deepen its engagement with the Shanghai Cooperation Organisation (SCO), a Eurasian political, economic and military organisation founded in 2001 by China, Kazakhstan, Kyrgyzstan, Russia, Tajikistan, and Uzbekistan.
Prime Minister Modi said India currently has observer status in the SCO, and was ready to accept additional responsibility, if asked to.
The two leaders appeared well prepared for the meeting as both of them referred to the statements made by the other before they assumed power, External Affairs Ministry spokesperson Syed Akbaruddin said.
Their talks centred around all aspects of the bilateral relations, regional and international matters, he said.
President Xi in particular referred to Modi's experience in Gujarat as the Chief Minister and his focus on development.
Modi also recalled his visits to China and underlined that relations between countries are built on the strength of relations between their people.
He expressed hope for increase in tourism and ties between the people of the two ancient civilisations.
Xi confirmed his visit to India in September and extended an invitation to Modi to visit China, which was accepted.
The dates will be decided by diplomatic channels, Akbaruddin said.
Asked if India has accepted the invitation for the APEC summit, he said November was a busy month with SAARC and G20 meetings scheduled but New Delhi considers the invitation as a significant gesture which will be given very serious consideration.
It was a substantive and a very cordial and warm meeting in which the two leaders struck a personal rapport which augurs well for the future, the spokesman said.
He said the prime minister emphasised that there should be no incidents on the border that would undermine the bilateral relations.
To a question on the incursions by the Chinese army on the border, Akbaruddin said India conveyed its concerns to China on the issue.
On his part, Modi also emphasised on the economic relations between the two countries and talked about cooperation in the infrastructure sector, industrial parks and investment.
He referred to the adverse trade imbalance against India and sought correction of the situation.
Xi acknowledged that there was a possibility of enhanced trade, particularly in the services sector from the Indian side and the increased Chinese tourist numbers to India.
Modi referred to the visit of Chinese travellers coming to Gujarat in the ancient period. Both the leaders touched on the historic and civilisational links between the two countries, especially the Buddhist links.
The Prime Minister referred to terrorism and extremism and said India and China should work together to fight the menace in the region in view of the common civilisational heritage they had.
Replying to questions whether any timeliness were discussed on resolving the border question, Akbaruddin said obviously since it was a first meeting between them they could not go beyond their initial references and stated positions.