After a rocky start to the holiday shopping season, U.S. retailers benefited from cheaper gas prices and an improving job market in the weeks leading up to Christmas, raising optimism that sales reached a three-year high.

Customer Growth Partners President Craig Johnson, who tracks the retail industry, now expects holiday sales to grow about 3.9 percent, a faster clip than he had previously projected as his "base case."

The biggest payroll gains since 1999 and the lowest gasoline prices in five years are prompting consumers to spend more liberally. The decline in gas prices, which are down 22 percent this month, could free up $3 billion in holiday consumption, Johnson said. The money has largely gone toward hard lines, such as televisions, headphones and toys, he said.

"This has been very much a hard lines Christmas," he said.

Retail sales between Thanksgiving and Christmas rose 5.5 percent, according to MasterCard Advisors, with jewelry and women's clothing ranking among the strongest categories. Johnson's research showed that this season was the best in years for both consumer electronics and toys, helped by products like Apple Inc.'s iPhone 6 and dolls from the Disney movie "Frozen."

The National Retail Federation has predicted that sales in November and December will gain 4.1 percent, the biggest increase since 2011. Holiday sales had climbed 3.1 percent last year, when severe winter storms kept shoppers home at the end of the season.

The Standard & Poor's 500 retailing index rose 0.5 percent Friday to 1,026.96. Shares of Wal-Mart Stores Inc., the world's largest retailer, rose 0.6 percent to $86.91. Best Buy Co. Inc., the biggest chain focused on electronics, also gained 0.6 percent, to $39.14.

Slower sales and foot traffic during the post-Thanksgiving weekend had stoked fears that this holiday season would be a disappointment as well. Spending tumbled an estimated 11 percent over the Black Friday weekend from a year earlier, the Washington-based NRF said. And more than 6 million shoppers who had been expected to hit stores never showed up.

It didn't help retailers that a worker slowdown at West Coast ports delayed the arrival of some merchandise.

In the end, though, discounts helped lure shoppers — even if they squeezed retailers' profit margins. Retail chains held sales throughout the season, rather than just concentrating on the Black Friday weekend.

E-commerce sellers also flooded consumers with deals. The average discount was $47.06 this year, up from $22.50 a year ago, according to data from TrackIF.com, a price-tracking website that monitors online sales.

The biggest gain in discounts was for televisions, with the average discount jumping 259 percent from $110.93 to $398.67. Berg said with new 4K and curved televisions on the market, there was price pressure on other models.

"They knew the more they could throw at people, the better they would do," said Doug Berg, TrackIF.com's chief executive.

Shipping services such as FedEx Corp. and United Parcel Service Inc. also fared better at getting last-minute orders to shoppers this year, said Steven Osburn, the director of supply-chain research at the consulting firm Kurt Salmon in Atlanta. Osburn and his team ordered packages from 60 retailers on the final day that each said they could deliver something by Christmas.

This year, 78 percent of the companies delivered all of the items on time, up from 59 percent a year ago. Calmer weather in most of the country and better preparation helped, Osburn said.

"There was a lot of money spent throughout the year to keep up with demand and avoid the issues we saw last year," he said.

Retailers still don't have the final read on the season, though. The week after Christmas, which always draws shoppers to use gift cards and make returns, is gaining importance, according to Johnson.

This year, the week after Christmas may be the second-biggest sales period of the season, topped only by the week before, Johnson said.