The benchmark Korea Composite Stock Price Index gained 0.57 points, or 0.02 percent, to 2,373.14.
Lee Kyung-min, an analyst at Daishin Securities, said investors purchased large-cap stocks in auto, tech and chemical sectors in anticipation of their strong earnings in the July-September quarter.
The main index had been on the decline for the seventh straight session mainly due to foreign selling amid tensions between North Korea and the United States.
US President Donald Trump said Tuesday he is "totally prepared" to use military options against North Korea. His latest warning came in response to Pyongyang's threat a day earlier to shoot down approaching American bombers, even if they are in international airspace.
Large-cap stocks were mixed across the board.
South Korea's No. 2 chipmaker SK hynix Inc. gained 0.97 percent to 83,200 won, and No. 1 steelmaker POSCO rose 1.28 percent to 315,500 won.
Meanwhile, market bellwether Samsung Electronics Co. lost 0.81 percent to 2,563,000 won, and top carmaker Hyundai Motor Co. shed 0.34 percent to 147,000 won.
The local currency closed at 1,149.10 won against the US dollar, down 8.40 won from the previous session's close.
Bond prices, which move inversely to yields, ended lower. The yield on three-year Treasurys gained 0.1 basis point to 1.888 percent, and the return on the benchmark five-year government bonds rose 0.3 basis point to 2.090 percent. (Yonhap)