The 26-year-old made 22 appearances in all competitions as Pools dramatically avoided relegation from League Two last term.
Compton will join the Glovers when the summer transfer window opens next month and is looking forward to getting started at Huish Park.
He told the club’s official website: “I cannot wait to get going now. I have heard so many good things about the club.
“I had some other offers but after meeting with the gaffer and his staff, I knew Yeovil Town was the club I wanted to join.”