Jefferies has upgraded PC giant Hewlett-Packard Co. (NYSE:HPQ) to "buy" from "hold," saying that the company is expected to deliver higher margins over long-term and is best positioned to benefit from the increasing demand for cloud services.

The brokerage said though HP has lower margins compared to its peers and investments the company needs to make will lead to near-term headwinds, it expects these investments could position the company well for longer-term opportunities and margin expansion.

"HP faces 4-6 quarters of investment in tablets and cloud services to offset the cannibalization of PCs, servers, and services; however, we believe HP's 3-year forward margins will be above where they are today (in contrast to Dell), as we believe HP is one of a handful of players that has or is close to having the components of a full stack," analyst Peter Misek wrote in a note to clients.

HP is one of a handful of players that has or is close to having the components of a full stack i.e., software, storage, networking and services, and the analyst sees significant opportunity in offering a vertically integrated cloud platform.

He said HP is one of the few companies that are well positioned to provide consumer, enterprise, and SMB cloud services.

HP's strategy has been to internally develop pieces of a cloud service while acquiring big chunks to create a more complete offering. This positions HP better than many others to address this new dynamic. In recent years, HP has spent $6.7 billion on software acquisitions, the analyst said.

"We expect cloud-based services to increase the velocity of change within IT, forcing faster innovation and deployments. We believe HP understands this and is positioning the company to execute to this strategy," Misek said.

Misek, who has a price target of $40 on HP stock, also raised HP's fiscal 2012 earnings estimates by 15 cents to $5.98 a share. Wall Street expects the company to earn $5.37 for fiscal 2012, according to analysts polled by Thomson Reuters.

Shares of HP closed Thursday's regular trading session at $31.05 on the NYSE.