PITTSBURGH, Pa. - The Pittsburgh Pirates and All-Star third baseman Josh Harrison have agreed to a lengthy contract extension that will keep him with the team through at least the 2018 season.

The deal, announced Wednesday, includes a club option for 2019 and 2010.

The 27-year-old Harrison finished second in the National League with a .315 batting average in 2014 while finishing ninth in the MVP race. Harrison spent the first three-plus years of his career as a utility player, earning a surprise All-Star berth last summer. He moved to third base permanently in the second half of the season while fueling Pittsburgh's run to a second straight playoff berth.

Harrison is a career .283 hitter, with 20 home runs, 98 RBI and 143 runs scored in 373 games with the Pirates.