May 12 (Reuters) - Affirm Holdings Inc raised its annual revenue forecast and said it has extended a multi-year partnership with Shopify in the United States, sending shares of the buy now, pay later (BNPL) firm up 23% aftermarket on Thursday.

San Francisco-based Affirm's third-quarter revenue surged 54%, surpassing the company's estimates, as it benefited from higher interest income and loan sale volumes as well as a surge in users.

"Our strong performance demonstrates our ability to drive growth with attractive unit economics, despite volatile market conditions," Chief Financial Officer Michael Linford said in a statement.

The company's results are in sharp contrast to fintech firm Upstart Holdings, which lowered its annual revenue outlook on Tuesday in a sign of declining loan demand as interest rates rise amid decades-high inflation.

Affirm said active merchants on its platform grew to 207,000 from 12,000 last year, while active consumers increased 137% to 12.7 million.

BNPL firms like Affirm earn from charging merchants a fee to offer their customers small, point-of-sale loans which are paid back in interest-free installments over a period of time, bypassing credit checks.

"Affirm is well-positioned for continued growth and long-term value creation ... We plan to achieve a sustained profitability run rate on an adjusted operating income basis by July 1, 2023," Chief Executive Officer Max Levchin said.

Affirm raised its full-year revenue forecast to between $1.33 billion and $1.34 billion, up from $1.29 billion to $1.31 billion earlier.

The company also narrowed its loss to $54.7 million, or 19 cents a share, from $287 million, or $1.23 a share, a year ago, as it recognized a $136.2 million gain in the third quarter.

Analysts had expected a loss of 51 cents a share, according to data from Refinitiv.

(Reporting by Mehnaz Yasmin in Bengaluru; Editing by Devika Syamnath)