Jamie Walker will leave Hearts permanently when his contract expires after signing for Bradford City.
The 28-year-old has been on loan at Valley Parade since January after becoming frustrated at a lack of game time at Tynecastle.
He's become a fans favourite after hitting four goals, and Mark Hughes has moved to tie him up.
The midfielder says it was an easy decision to sign for the Bantams.
Walker said: “It feels great. This was the only football decision I wanted to make, and I am delighted to be here permanently.
“It has been a tough season for the club, but the ambition is something that was a big factor in me signing.
“The manager has Premier League experience and the club is heading in the right direction. The last three performances have shown that.
“Hopefully, we can use it as a springboard heading into next season and achieve what we want to achieve.”
Mark Hughes added: “Jamie’s signing is one we are delighted to have got over the line, and we are looking forward to having him with us for at least the next two seasons.
“He is a talented player and one who brings an awful lot to our side in terms of his character.
“Jamie will be able to take a lot of encouragement from the finish to the season he has had, and we can do the same as a collective.
“He has a good eye for goal, and wants to be a part of this club’s success, so to have him tied down to a long-term contract is a huge boost for us.”
Robbie Neilson spoke in January about not wanting to lose the player, but in the end was sympathetic to his desire for more football.
It brings to an end Walker's second spell with his boyhood club after he re-joined in 2019.
He left for the first time to sign for Wigan Athletic and also enjoyed a loan spell with Peterborough United.