Nokia denied on Thursday that it is in talks to buy Juniper Networks, following a CNBC report that it was preparing a deal for the company.

"Nokia is not currently in talks with, nor is it preparing an offer for, Juniper Networks related to an acquisition of that company," the Finnish company said.

Sources earlier told CNBC that a deal was in the making that would marry Juniper, a multibillion-dollar networking company, with Nokia's infrastructure resources.

Shares of Juniper were up more than 2 percent in after-hours trading.

Prior to the Nokia statement, a Juniper spokesperson declined to comment, citing a policy against addressing "market speculation or rumors."

Juniper, based in Sunnyvale, California, offers services like security and routing. While Finland-based Nokia is best known today for its iconic mobile phones, it has been in the telecom equipment business since the 1880s. The company shifted focus to the Internet of Things, 5G and the cloud after its mobile phone business was bought and sold by Microsoft.

Nokia purchased telecom company Alcatel-Lucent for about $16.6 billion last year as part of its latest transformation.

Juniper Networks has deep roots in Silicon Valley. Founder Pradeep Sindhu is an alumnus of Xerox's Palo Alto Research Center and Sun Microsystems.

— CNBC's Alex Sherman contributed to this report.