Shares of Samsung surged on Wednesday after the South Korean technology giant's third quarter earnings guidance blew past expectations, suggesting the company is getting back on track after a number of weak quarters.

The company estimated its third-quarter profit rose 79.8 percent on year to 7.3 trillion won ($6.29 billion), its first quarterly profit gain in two years and its biggest since the first quarter of 2014. This compares with 6.7 trillion won forecast by analysts in a Reuters poll.

It also expects its third-quarter revenue to have risen 7.5 percent from a year earlier to 51 trillion won. The firm will report its full results in late October.

Investors cheered the guidance, sending Samsung's stock soaring 8.7 percent to 1.251 million won, their highest since late July.

Read MoreSamsung at center of energy test storm



"It's a very pleasant surprise, this is much stronger than consensus. That clearly shows Samsung's earnings recovery is well on track," said Daniel Kim, analyst at Macquarie Equities Research.

Kim pins the earnings surprise on two factors: higher-than-expected margins for the company's display panel business as well as stronger-than-expected shipments of premium smartphones Galaxy Note 5 and Galaxy S6 edge plus in September - a welcome development for the company's mobile division which has been struggling in the face of waning global demand and intensifying competition from Apple and low-cost manufacturers.