SEOUL, South Korea — In a significant step toward overcoming lingering historical animosities with its former colonial master, the South Korean government has unexpectedly announced that it will sign a treaty with Japan on Friday to increase the sharing of classified military data on what analysts cite as two major common concerns: North Korea’s nuclear and missile threats and China’s growing military might.

The announcement set off a political firestorm in South Korea, where resentment of Japan’s early 20th-century colonization remains entrenched and any sign of Japan’s growing military role is met with deep suspicion. The opposition accused President Lee Myung-bak of ignoring popular anti-Japanese sentiments in pressing ahead with the treaty, the first military pact between the two nations since the end of colonization in 1945.

North Korea accused Mr. Lee’s government of “selling the nation out.”

The accord, the General Security of Military Information Agreement, provides a legal framework for South Korea and Japan to share and protect classified and other confidential data. Cho Byung-jae, the spokesman of the South Korean Foreign Ministry, said the South Korean ambassador to Tokyo, Shin Kak-soo, and Japan’s foreign minister, Koichiro Gemba, plan to sign the treaty on Friday, after the Japanese cabinet’s approval.

The United States has been urging the two countries to strengthen military ties, so the three nations can deal more efficiently with threats from North Korea.