Salesforce Inc. shares rallied in the extended session Tuesday after the cloud-based customer-relationship-management company topped Wall Street estimates for the quarter and hiked its earnings forecast for the year while lowering its revenue guidance.

Salesforce  CRM, -2.94% shares surged 6% after hours, following a 2.9% decline in the regular session to close at $160.24.

The company reported fiscal first-quarter net income of $28 million, or 3 cents a share, compared with $469 million, or 50 cents a share, in the year-ago period. Adjusted earnings were 98 cents a share, compared with $1.21 a share in the year-ago period.

Revenue rose to $7.41 billion from $5.96 billion in the year-ago quarter.

Analysts surveyed by FactSet had estimated earnings of 94 cents a share on revenue of $7.38 billion, based on Salesforce’s forecast of 93 cents to 94 cents a share on revenue of $7.37 billion to $7.38 billion

“There is no greater measure of our resilience and the momentum in our business than the $42 billion we have in remaining performance obligation, representing all future revenue under contract,” said Marc Benioff, Salesforce chairman and co-chief executive, in a statement.

Salesforce expects adjusted second-quarter earnings of $1.01 to $1.02 a share on revenue of $7.69 billion to $7.7 billion, while analysts surveyed by FactSet had forecast $1.14 a share on revenue of $7.77 billion.

For fiscal 2023, Salesforce increased its earnings outlook while trimming its revenue forecast. The company forecast adjusted earnings of $4.74 to $4.76 a share on revenue of $31.7 billion to $31.8 billion. Back in March, the company had forecast adjusted earnings of $4.62 to $4.64 a share on revenue of $32 billion to $32.1 billion.

Analysts expect $4.66 a share on revenue of $32.06 billion for the year.

“Our portfolio of products remains well-positioned to serve our broad set of customers,” said Amy Weaver, Salesforce’s chief financial officer, in a statement. “We have been able to deliver strong growth while also driving disciplined decision-making, enabling us to expand our operating margin guidance for the full year.”

Salesforce is now forecasting operating margins of about 20.4% for the year, compared with a forecast of about 20% back in March.

Over the past 12 months, Salesforce shares have fallen nearly 33%, while the iShares Expanded Tech-Software Sector ETF  IGV, -1.98% has dropped 20%, the S&P 500 index  SPX, -0.63%   has slipped 1.7%, the tech-heavy Nasdaq Composite Index  COMP, -0.41%  has declined 12.1%, and the Dow Jones Industrial Average  DJIA, -0.67%   — which counts Salesforce as a component — has shed 4.5%.