BlackBerry, the Canadian technology company, reported an unexpected profit for the first quarter, driven by increased client spending in its cybersecurity division and continued success in the automotive sector with its enterprise software offerings.

The news had an immediate impact on BlackBerry’s stock, with US-listed shares soaring over 20% during pre-market trading on Thursday.

With rising security threats in the IT industry, BlackBerry has capitalized on the growing demand for its cybersecurity products. For the quarter ending on May 31, the company posted a profit of 6 cents per share, defying analysts’ expectations of a 5 cent per share loss.

Furthermore, BlackBerry’s total revenue of $373 million exceeded the average estimate of $160.4 million from analysts surveyed by IBES data provided by Refinitiv. Notably, the cybersecurity business unit saw a 5.5% sequential increase in revenue, reaching $93 million. Additionally, licensing and other services generated $235 million in revenue, primarily driven by proceeds from patent sales.

As part of its strategic shift, BlackBerry, renowned for its business smartphones, closed its flagship business last year and focused on selling its legacy patents associated with mobile devices. In line with this strategy, the company inked a deal in March to sell patents related to its mobile devices to Malikie Innovation Limited for a potential sum of up to $900 million.

Based in Waterloo, Canada, BlackBerry had previously announced its intentions to explore strategic alternatives, including potentially separating its core businesses: cybersecurity and software systems.