Cargo aircrafts from UPS, FedEx and West Air Europe are parked at Cargo City at Arlanda airport in Stockholm.

Goldman Sachs is recommending buying FedEx and UPS, seeing more than 20% gains for both stocks, as the logistics companies are seen as competitive against new entrants like Amazon.

The bank initiated its coverage of FedEx with a buy rating and a 12-month price target of $200, which represents 24% upside. UPS also earned a buy rating from Goldman and a 12-month price target of $123, which could translate into a 21% gain.

The firm also called FedEx its favorite pick of the group, adding the stock to its conviction buy list.

"We believe that recent concerns about 'digital disruptors' and Amazon are overdone in the near term," Goldman analyst Jordan Alliger said in a note to clients Wednesday. "Widely reported overhangs from 'big-name' entrants like Amazon and Uber Freight ... should not be the main focus currently, given the numerous self-help initiatives that could improve overall sector financials."

Shares of FedEx rose 0.49% on Wednesday, while UPS was little changed.

Amazon is more aggressively building out its own shipping and delivery network. FedEx announced last month that it won't renew its express U.S. shipping contract with Amazon, which raised concerns about FedEx's business going forward. Goldman noted FedEx as well as UPS have "significant network investment centered on automation, new hubs, and optimization" to be able to compete with the e-commerce giant.

"Logistics incumbents have technology too. The digital 'disruptor' threat is real, but large scale incumbents offer significant in-house technology to compete long term," Alliger said.

FedEx's stock has been under pressure this year, falling 0.85%, while shares of UPS also significantly underperformed the market, eking out only a 4.2% gain for 2019. Goldman said the logistics sector's valuation has now reached "compelling" levels.

"At current levels, we believe the market incorporates much of the risk associated with trade issues, 2019 EPS concerns from soft volumes, and perceived threats from non-traditional entrants. With stocks down 17% on average, investors will look for 2020/2021 EPS turnaround stories — this space could be at the forefront," Alliger said.