Shares of Intel initially rose 2 percent in premarket trading after the announcement but was down 1.8 percent in morning trading.
Krzanich was named CEO and elected to the board in May 2013, according to a summary of his biography on Intel's website. Before that, he served as executive vice president and chief operating officer. He joined Intel in 1982.
He led Intel's transformation from a PC-centric to a data-focused company, delivering the technology foundations for the new data economy, according to the company's most recent 10K statement.
"The Board believes strongly in Intel's strategy and we are confident in Bob Swan's ability to lead the company as we conduct a robust search for our next CEO," Intel Chairman Andy Bryant said in a statement. "Bob has been instrumental to the development and execution of Intel's strategy, and we know the company will continue to smoothly execute. We appreciate Brian's many contributions to Intel."
Intel's stock has risen about 120 percent during Krzanich's tenure as CEO.
Also Thursday, Intel raised its guidance for the second quarter. The company said it now expects adjusted earnings of 99 cents per share on $16.9 billion in revenue. Intel previously forecast second-quarter earnings of 85 cents a share on $16.3 billion in revenue.
—CNBC's David Faber and Jordan Novet contributed to this report.
Correction: This story was revised to remove an incorrect title for Krzanich. He was a member of the board.
Here's Intel's full release:
Intel Corporation today announced the resignation of Brian Krzanich as CEO and a member of the Board of Directors. The Board has named Chief Financial Officer Robert Swan Interim Chief Executive Officer, effective immediately.
Intel was recently informed that Mr. Krzanich had a past consensual relationship with an Intel employee. An ongoing investigation by internal and external counsel has confirmed a violation of Intel's non-fraternization policy, which applies to all managers. Given the expectation that all employees will respect Intel's values and adhere to the company's code of conduct, the Board has accepted Mr. Krzanich's resignation.
"The Board believes strongly in Intel's strategy and we are confident in Bob Swan's ability to lead the company as we conduct a robust search for our next CEO. Bob has been instrumental to the development and execution of Intel's strategy, and we know the company will continue to smoothly execute. We appreciate Brian's many contributions to Intel," said Intel Chairman Andy Bryant.
Intel expects to deliver a record second quarter, with revenues of approximately $16.9 billion and non-GAAP EPS of approximately $0.99. With accelerating data-centric revenue, the company is off to an excellent start in the first half of the year and expects 2018 to be another record year. Intel will provide full second quarter results and an updated outlook for the full year on the second quarter earnings call on July 26.
As Interim CEO, Swan will manage operations in close collaboration with Intel's senior leadership team. Swan has been Intel's CFO since October 2016 and leads the global finance, IT, and corporate strategy organizations. He previously spent nine years as CFO of eBay Inc. Earlier, he was CFO of Electronic Data Systems Corp and TRW Inc. He has also served as CEO of Webvan Group Inc.
Swan added, "Intel's transformation to a data-centric company is well under way and our team is producing great products, excellent growth and outstanding financial results. I look forward to Intel continuing to win in the marketplace."
The Board has a robust succession planning process in place and has begun a search for a permanent CEO, including both internal and external candidates. The Board will retain a leading executive search firm to assist in the process.