The 32-year-old, who made his debut for the county in 2003, has played 556 games for Somerset across all formats.
"I love playing for the club and honestly can't imagine playing anywhere else," he told the club website.
Director of Cricket Matt Maynard added: "He is an outstanding professional and epitomises everything we are about."
Hildreth was a key part of the Somerset side that finished second in the County Championship last season and has scored 14,653 first-class runs in total.
Somerset batsman James Hildreth has signed a new four-year contract with the County Championship Division One side until the end of the 2021 season.