Cisco Systems Inc. has won a legal battle against counterfeit versions of key networking equipment, securing an injunction that requires big online marketplaces, including Amazon.com Inc. and Chinese rival Alibaba Group Holding Ltd. to halt the sale of some knockoffs.

Cisco secured the sales ban in a temporary injunction seen by The Wall Street Journal. The company had argued that counterfeit items threatened U.S. national security and health systems, in part, because the items were more failure prone and the software would...