TAMPA, Fla. — If the San Diego Padres had stayed away from elite free agents this winter, people would have understood. They gave out the richest contract on last year’s free-agent market, yet finished with their worst record in a decade.

But the Padres could not resist the allure of Manny Machado, and on Tuesday they established a new standard for free agency to get him. They agreed with Machado on a 10-year contract worth $300 million, the most ever guaranteed to a free agent.

The Padres did not announce the agreement, because Machado must first pass a physical, but the deal — which includes an opt-out clause after 2023 — was confirmed by a person in baseball with direct knowledge of it.

Machado, a four-time All-Star at third base and shortstop, spent last season with the Baltimore Orioles and the Los Angeles Dodgers, hitting .297 with 37 homers and 107 R.B.I. He joins first baseman Eric Hosmer — who signed with the Padres last February for eight years and $144 million — in an effort to revive a team that went 66-96 last season, its eighth losing record in a row.