Mr Xi said "achieving total unity" was the "collective hope of all Chinese people" and any attempts to divide it were "doomed to fail".
The speech was a strong warning against any attempt at separatism from places like Taiwan and Hong Kong.
Mr Xi also warned China could not be complacent about its development.
Meanwhile, Premier Li Keqiang used his once-a-year news conference to say China was committed to global co-operation on trade.
He said China would further open up its economy and "ensure that both domestic and foreign firms" were "able to compete on fair terms in China's large market". Chinese officials have made similar pledges in the past.
The premier's comments are a marked contrast to the recent protectionist rhetoric and threats of tariffs from the Trump administration in the US.
'Punished by history'
Xi Jinping became president in 2013 and now looks likely to lead China indefinitely, after the National People's Congress (NPC) - a rubber-stamp parliamentary session that meets once a year - voted to remove a two-term limit on the presidency from the constitution.
He is now considered the most powerful Chinese leader since Mao Zedong, the founder of modern China, and has further cemented his position by moving many of his key allies in to leadership roles during the NPC.
Image copyrightAFPImage captionThe president urged lawmakers to rule in the interest of the people
In his speech in the Great Hall of the People, Mr Xi highlighted major achievements of Chinese history, like the invention of gunpowder and the writings of Confucius.
He laid out his own grand vision for China, saying history had proven that "only socialism can save China".
Chinese people, he said, "have the spirit of fighting the bloody battle against our enemies to the bitter end".
More about: China