Intel's CEO resigned in a surprise announcement on Thursday.

Intel said it had discovered he had a "past consensual relationship" with an employee in a violation of company policies.

CFO Bob Swan will take over as interim CEO.

Intel's CEO, Brian Krzanich, resigned on Thursday, the company said in an announcement.

CFO Bob Swan will take over as interim CEO, according to the release.

Intel said it found that Krzanich had a "past consensual relationship with an Intel employee" that ended up being a violation of company policies.

Krzanich had been an Intel employee since 1982. He became CEO in 2013.

Krzanich was in charge when Spectre, a serious security bug affecting most Intel processors, was discovered earlier this year, and as CEO, he apologized on behalf of the company. Krzanich also sold $24 million in stock late last year, raising questions at the time.

Recently, Intel started focusing its business on building chips for servers and cloud-computing companies. It also makes chips for laptop and desktop computers running Windows or MacOS. The company does not make many chips for smartphones, though Apple has in the past few years started to buy Intel modems for iPhones.

Intel's famous relentless technical progress, known as Moore's law, suggested its chips would get smaller and faster at a regular rate. But Intel has also recently had difficulties manufacturing next-generation "10-nanometer" chips, and performance gains have been limited in recent years.

Intel's share price rose to $53.46 on Wednesday, up from $23.95 in May 2013, when Krzanich took over as CEO.

Intel reports second-quarter earnings on July 26.

Here's the entire announcement: