By Tim Higgins and Matt Grossman

Amazon.com Inc. has reached an agreement to acquire autonomous-car developer Zoox, the two companies said Friday.

The Wall Street Journal reported in May that the Seattle-based e-commerce giant was in advanced talks to buy Zoox, at a price lower than the $3.2 billion valuation Zoox had achieved in a previous fundraising round. Zoox was founded in 2014 and grew quickly amid expanding interest in autonomous vehicles and ride hailing but has more recently struggled to raise funding.

The deal with Amazon is valued at slightly more than $1.2 billion, according to a person familiar with the deal. The plan is for Zoox to continue development of its robot taxi, an electric vehicle that it has been working on, with Amazon investing money in Zoox so it can deploy these vehicles.

It was the latest exchange between the rival billionaires who are increasingly competing for the future of transportation whether it be driverless cars or space rockets. Earlier this month, Mr. Musk on Twitter called for a breakup of Amazon, saying "monopolies are wrong!"

Hours after the deal was announced, Tesla Inc. Chief Executive Elon Musk weighed in on Twitter, calling Amazon founder Jeff Bezos a copy cat.

Investor enthusiasm for Mr. Musk's ability to develop driverless cars has helped boost Tesla shares in recent years. The electric-car maker has been on the forefront of deploying driver-assistance systems and has set ambitious goals, though Mr. Musk has missed several self-imposed deadlines.

Amazon has shown interest in autonomous vehicles, in part as a way to bring more delivery services in house. Previous dealings include participation in fundraising rounds for Aurora Innovation Inc. and Rivian Automotive LLC, two other companies that are working on autonomous-vehicle development.

The deal brings Amazon into the ranks of corporate titans that have established substantial in-house autonomous-vehicle efforts. In 2016, General Motors Co. spent more than $1 billion to acquire Cruise Automation, and Uber Technologies Inc. acquired an autonomous-vehicle startup for $680 million. Alphabet Inc. is working to develop autonomous vehicles through its Waymo subsidiary, which began as a division of Google.

Write to Matt Grossman at matt.grossman@wsj.com