(Corrects name of China's ruling party in paragraph 22)
* S.Korea, China to hold summit on sidelines of Nov. APEC meeting
* Worsening N.Korea-China ties may have contributed to agreement -Blue House
* S.Korean China-reliant, tourism-related stocks surge
* Multimedia package www.reuters.com/north-korea/
By Christine Kim and Ben Blanchard
SEOUL/BEIJING, Oct 31 (Reuters) - Seoul and Beijing agreed on Tuesday to work swiftly to get relations back on track following a year-long standoff over the deployment of a U.S. anti-missile system in South Korea which pummelled South Korean business interests in China.
The installation of the U.S. Terminal High Altitude Area Defense (THAAD) system had deeply angered China and spilled over into tourism, trade and even cultural ties with South Korea.
"Both sides shared the view that the strengthening of exchange and cooperation between Korea and China serves their common interests and agreed to expeditiously bring exchange and cooperation in all areas back on a normal development track," South Korea's foreign ministry said in a statement on Tuesday.
The unexpected detente comes just days before U.S. President Donald Trump begins a trip to Asia where North Korea will again take centre stage.
South Korea's President Moon Jae-in will also meet with China's President Xi Jinping on the sidelines of an upcoming summit of Asia-Pacific Economic Cooperation (APEC) countries in Vietnam on Nov. 10-11, South Korea's presidential office said.
The two heads of state are likely to discuss North Korea's missile and nuclear programme as well as ways to develop bilateral ties, a senior South Korean presidential Blue House official later told reporters, declining to be identified due to the sensitivity of the matter.
Pyongyang has undertaken an unprecedented missile testing programme in recent months, as well as its biggest nuclear test yet in early September, as it seeks to develop a powerful nuclear weapon capable of reaching the United States.
The moves have angered China, North Korea's only major ally, and drawn further tough sanctions from the United Nations and the United States.
The recent deterioration in ties between China and North Korea may have contributed to Tuesday's agreement, the Blue House official said.
The head of NATO on Tuesday urged all United Nation members to fully and transparently implement sanctions against North Korea, which he said has emerged as a global threat able to fire ballistic missiles as far as Europe and North America.
"North Korea's ballistic and nuclear tests are an affront to the United Nations Security Council," North Atlantic Treaty Organization Secretary General Jens Stoltenberg said in Tokyo, where he met Japanese Prime Minister Shinzo Abe.
Separately, a South Korean lawmaker said North Korea probably stole South Korean warship blueprints after hacking into a local shipbuilder's database last April.
In a statement coordinated with South Korea's announcement, China's foreign ministry said the two countries would get relations back onto a normal track "at an early date".
South Korea recognised China's concerns on the THAAD issue and made it clear the deployment was not aimed at any third country and did not harm China's strategic security interests, China's foreign ministry said.
China reiterated its opposition to the deployment of THAAD, but noted South Korea's position and hoped South Korea could appropriately handle the issue, it added.
South Korean companies operating in China have suffered since the spat erupted last year, although Beijing has never specifically linked its actions to the THAAD deployment.
"China repeated this stance during discussions, saying difficulties faced by South Korean companies were prompted by individual Chinese citizens angered by the THAAD deployment," the Blue House official said, adding that improvements for South Korean companies would come slowly.
Lotte Group, which provided the land where THAAD was installed, has suffered most. It faces a costly overhaul and is expected to sell its Chinese hypermarket stores for a fraction of what it invested.
A spokesman for Lotte Corp, the holding company of Lotte Group, expressed hope South Korean firms' activity in China would improve following the announcement.
South Korean tourism and retail shares rallied, with Lotte Tour surging more than 18 percent and Lotte Shopping up as much as 5.7 percent.
Shares of Asiana Airlines gained as much as 4.6 percent.
Hopes have been growing for a thaw in the frosty bilateral ties following China's recently completed Communist Party conclave, during which President Xi Jinping cemented his status as China's most powerful leader after Mao Zedong.
Earlier this month, South Korea and China agreed to renew a $56 billion currency swap agreement, while Chinese airlines are reportedly planning to restore flight routes to South Korea that had been cut during the spat.
Tuesday's agreement came after high-level talks led by Nam Gwan-pyo, deputy director of national security of the Blue House, and Kong Xuanyou, assistant foreign minister of China and the country's special envoy for North Korea-related matters.
Reporting by Christine Kim and Hyonhee Shin in SEOUL, Ben Blanchard in BEIJING; Additional reporting by Dahee Kim and Joyce Lee; Editing by Lincoln Feast