Target tgt investors breathed a sigh of relief on Wednesday after the retailer reported that vigorous e-commerce sales growth had returned after a previous slowdown. Its stock rose by 3%.

Digital sales at the discount retailer rose 34% during the holiday quarter, buoyed by strong volume on Black Friday and Cyber Monday and an aggressive slate of promotions. The impressive showing, which contrasted with an 8% e-commerce growth rate at Walmart wmt reassured Wall Street that Target’s billion-dollar investments in its e-commerce operations are paying off. The uptick at Target ended three straight quarters of slowing growth at the retailer, just in time for Christmas.

Target pulled out all the stops to win its share of digital holiday sales; tactics included a 15% off everything on target.com on Cyber Monday (that almost caused a site shutdown), 10 days of online sales leading up to Thanksgiving, and free shipping and free returns on orders of any size in November and December, a move more commonly used by upscale retailers like Nordstrom jwn , which enjoys higher profit margins.

The approach worked. Target’s online growth spurt contributed more to overall sales growth during the fourth quarter than any preceding quarter, accounting for two-thirds of comparable sales improvements at Target. (Comparable sales rose 1.9% for the quarter, compared to 0.6% at Walmart U.S.) And, most importantly, digital sales help bring 1.3% more shoppers to physical Target stores, the fifth straight quarter of increases. This marked a crucial development for Target, as it tries to fight off Amazon.com. amzn . (Target’s growth outpaced Amazon’s, but its digital business is tiny, making the comparison unfair.)

Almost a year ago, Target announced an ambitious e-commerce plan, saying it would spend about $1 billion in 2015 on its digital business, roughly as much as it planned to spend on its stores. That included equipping more stores to help out with e-commerce by shipping orders and improving in-store pick up of online orders. That helped the company avoid missed sales: Operations chief John Mulligan told analysts on a conference call that 40% of online orders picked up in store or shipped from a store were items that were out of stock at Target’s main distribution facilities.

A third of digital orders at Target during the holiday season were picked up in store or filled from inventory in stores. In the days right before Christmas, about half of target.com orders were picked up in one of Target’s 1,800 stores.

“Our fourth quarter experience demonstrated the power of relying on our stores to fill digital demand,” Mulligan told Wall Street analysts on a conference call.

 

Still, Target’s online growth came at a cost to margins because of the free shipping and returns and the deep discounting. (Walmart maintained its $50 order minimum, likely costing it some business.) Gross merchandise margins fell to 27.9% in the quarter, down from 28.4% a year earlier. And last year, Target CEO Brian Cornell told Wall Street to expect 40% growth in e-commerce; it delivered 31% growth for the year.

“Digital does have a little more challenged economics,” Target Chief Financial Officer Cathy Smith said on a call with analysts. At the same time, Target made progress in its overhaul of merchandise with higher profit margins like home goods, fashion, and kids products. Home goods’ comparable sales rose 4%, their highest clip in a decade.