The holiday shopping season, a crucial period for retailers that can account for up to 40 percent of annual sales, brought record-breaking online and in-store spending this year of more than $800 billion (597 billion pounds), according to Mastercard Inc's (>> MasterCard) analytics arm.

Stakes are particularly high this year for traditional retailers that have invested heavily in technology and free delivery and returns, determined to stay relevant in a market increasingly dominated by Amazon.com Inc (>> Amazon.com).

"It has been an extremely positive holiday season in terms of sales both for brick-and-mortar and for online businesses," said Shelley Kohan, a Retail Fellow at analytics firm RetailNext.

Preliminary numbers show total holiday sales will exceed RetailNext's initial forecast of a 3.8 percent increase from last year. "All the economic indicators were very strong, and so I think consumers were more willing to open up their wallets and purses and spend more," Kohan added.

RetailNext and most other analytics firms and industry groups - including Adobe Analytics and the National Retail Federation - are due to publish holiday sales data in January.

Mastercard Inc (>> MasterCard) said on Tuesday that a late-season rally had driven an 18.1 percent rise in online sales. Department store chain Macy's Inc (>> Macy's Inc) and Target Corp (>> Target Corporation) both noted increased activity during that time.

Target spokesman Joshua Thomas told Reuters that during the week before Christmas the company had seen a marked increase in shoppers picking up online orders in stores, while Macy's spokeswoman Blair Rosenberg said last-minute shoppers boosted fragrance sales during that period.

The S&P retail index <.SPXRT> was flat on Wednesday.

SANTA'S LITTLE HELPERS

Package delivery companies that handle returns for retailers have benefited from booming delivery volumes in recent years, but also have had to invest billions of dollars to upgrade and expand their networks to cope as e-commerce purchases surge to new heights.

Delivering individual packages to shoppers - and picking up returns - is a lower margin business for delivery companies, which make more when they deliver in bulk to businesses.

United Parcel Service Inc (>> United Parcel Service), the world's largest package delivery company, said on Wednesday it was on track to return a record number of packages this holiday, having handled more than 1 million returns to retailers daily in December.

That pace is expected to continue into early January, UPS said, and would likely peak at 1.4 million on Jan. 3, which would be a fifth consecutive annual record, up 8 percent from this year.

Rival FedEx Corp (>> FedEx Corporation) said it experienced another record-breaking peak shipping season, but declined to provide specifics. The company's Chief Marketing Officer Rajesh Subramaniam told analysts last week about 15 percent of all goods purchased online are returned, with apparel running at about 30 percent.

UPS has worked for years to increase its ability to forecast customer shipping demands to handle major package volume spikes ahead of the holidays. It has also raised shipping rates and added 2018 peak-season surcharges.

The returns delivered in 2017 are part of the 750 million packages UPS said it expects to deliver globally during the peak shipping season from the U.S. Thanksgiving holiday through New Year's Eve. That is an increase of nearly 40 million over the previous year.

UPS and FedEx shares both ended up slightly on Wednesday.

(Reporting by Eric M. Johnson in Seattle; Additional reporting by Richa Naidu in Chicago; Editing by Bill Rigby)

By Eric M. Johnson and Richa Naidu