SAN FRANCISCO — Apple, Google and two other Silicon Valley companies have agreed to pay $415 million in a second attempt to resolve a class-action lawsuit alleging they formed an illegal cartel to prevent their workers from leaving for better-paying jobs.

The settlement filed Thursday in a San Jose, California, federal court revises a $324.5 million agreement that U.S. District Judge Lucy Koh rejected as inadequate five months ago. Koh indicated that she believed the roughly 64,000 workers in the case should be paid at least $380 million, including attorney fees.

If Koh approves the latest settlement, it would avoid a potentially embarrassing trial over claims that Apple Inc., Google Inc., Intel Corp. and Adobe Systems Inc. secretly agreed not to recruit each other’s employees from 2005 to 2009.

The alleged collusion stopped after the U.S. Justice Department opened an investigation that culminated with an antitrust complaint being filed against Apple, Google and the other participating companies in 2010. The Justice Department’s case was settled without the companies admitting any guilt or paying any fines.

The evidence gathered in the ensuing class-action lawsuit has exposed Apple and Google emails that have cast some of their top executives in an unflattering light.

Apple’s late CEO Steve Jobs is depicted as the conniving ringleader of a scheme designed to minimize the chances that the top computer programmers and other talented employees would defect to other technology companies. The lawsuit contends the secret “no-poaching” agreements orchestrated by Jobs suppressed the wages of the employees, many of whom were already making more than $100,000 annually.