BALTIMORE (AP) — J.J. Hardy can earn $54.8 million over four years in his new contract with the Baltimore Orioles.

The shortstop, who could have become a free agent, is guaranteed $40 million over three seasons in Thursday’s deal: $11.5 million next year, $12.5 million in 2016 and $14 million in 2017.

READ MORE: 29-Year-Old Man Dies After Being Fatally Stabbed In Baltimore Thursday

His agreement includes a $14 million team option for 2018 with a $2 million buyout. The option would become guaranteed if he has 600 plate appearances in 2017 or 1,150 in 2016 and 2017 combined, and if he passes a physical at the end of the 2017 season.

READ MORE: Baltimore Rowing Club Receives Grant to Get More Student-Athletes of Color Involved

Hardy can earn $700,000 annually in performance bonuses: $350,000 each for 125 and 135 games started. The performance bonuses are payable on the July 1 four years after the season in which they are earned.

MORE NEWS: Flash Floods In Maryland Close Some Schools, Roads; Several Rescued In High Water, MSP Responds To More Than 500 Calls

(Copyright 2013 by The Associated Press. All Rights Reserved.)