Samsung Electronics Co. shares climbed by the most in more than two months on Thursday despite softer second-quarter preliminary earnings.

Shares in the South Korean tech giant rose as much as 3.7% to 58,500 won ($44.82) in early afternoon trade, on course to notch the steepest daily percentage rise since April 28, when they jumped 4%.

The rally staged by the blue-chip stock, which accounts for 19% of the Kospi’s total market value, helped the benchmark index gain 1.8%.

The earnings guidance Samsung gave early on Thursday was somewhat downbeat, with the company saying that its recent string of record quarterly results likely ended in the April-June period as the global tech boom faded.

It expects revenue and operating profit to come in at KRW77 trillion and KRW14 trillion, respectively, in the second quarter–marginally weaker than the results of KRW77.78 trillion and KRW14.12 trillion recorded in the first quarter.

Hyundai Motor Securities analyst Greg Roh attributed Thursday’s rally to a correction to recent steep losses.

“The market has already priced in Samsung’s softer second-quarter results. Some investors think the recent selloff was overdone,” Mr. Roh told Dow Jones Newswires. “The rally today also reflects investor confidence in Samsung’s resilience despite market worries.”

Samsung, the world’s top memory-chip and smartphone maker, has a diverse product lineup and is both a device maker and a parts supplier.

So far this year, shares of the tech-industry bellwether have lost about 25%.

The global tech sector is facing headwinds from soaring inflation, which is weighing on consumer spending, and also grappling with the ebbing of pandemic-driven demand.

Write to Kwanwoo Jun at kwanwoo.jun@wsj.com