Heart of Midlothian
On 18 January 2013, he joined Scottish Premier League side Heart of Midlothian on loan from Liverpool until the end of the season. He was given the squad number four and made his debut the following day from the start at Celtic Park, in a Scottish Premier League match against Celtic, in a 4–1 defeat.
He then played in the Scottish League Cup for the first time in three years when Hearts faced Inverness Caledonian Thistle, which Hearts won on a penalty-shootout after a 1–1 draw after extra-time. The win put Hearts into the final. However, there was controversy over his appearance when he last played in the Scottish League Cup, resulted in him receiving a red card three years ago. The Scottish FA stated that Wilson was indeed eligible, stating he served his ban at the beginning of season 2010/11 and the SFA does not operate competition-specific disciplinary procedures. In the final against St Mirren, Wilson started in the match, partnering a central defender with captain Andy Webster. The match ended with St Mirren winning 3–2 against, having gained revenge on him for three years ago. Since moving to Hearts, Wilson became a regular in the first team and was willing to stay at Hearts for the long term.
On 27 May 2013, it was announced that Wilson would sign a permanent deal with Hearts after his Liverpool contract was up in the summer. The move was initially blocked by the SPL following the club entering administration and being unable to register new players, but this was later rescinded and Wilson was confirmed as a Hearts player on 30 June. On 2 July, Hearts made Wilson club captain at the age of just 21, which manager Gary Locke quote "a big responsibility for him". It is thought this is the reason for Wilson re-signing with the club.
Wilson's first game at Hearts as captain came in the opening game of the season, in a 1–0 defeat to St Johnstone. After winning 3–1 against Aberdeen on 24 August 2014, Wilson was involved in a tunnel incident that saw him receive a one match ban. Then in November, Wilson played a role in giving Hearts points in two games when he assisted one goal in a 3–1 win over Aberdeen and another, in a 2–2 draw against Ross County. Soon, Wilson was on the sideline when he had tonsillitis and scored on his return in a 3–3 draw against St Johnstone. Wilson scored his second goal of the season a month later on 21 March 2014, in a 2–1 loss against Dundee United. His third goal came in a 4–2 defeat to Partick Thistle on 7 May 2014. However, Wilson was unable to help the club survive relegation from the Scottish Premiership. Despite this, Wilson made thirty-three appearances and scored three times in the league. Despite the relegation, Wilson vowed to help the club bounce back to the Scottish Premiership, as he was keen to stay at Hearts when they would be in the Scottish Championship.
In his second season at Hearts, Wilson stated he was looking forward to playing in the Scottish Championship, and he scored the club's first goal of the season in the Championship against his former club Rangers which he refused to celebrate. Hearts went on to win 2–1. Wilson was soon on the sidelines when he strained his hamstring. Wilson made his return against Queen of the South and scored his second goal of the season, as well as providing two assists in a 4–1 win. Wilson captained Hearts through the 2014/15 season as they won the Championship and gained promotion to the Premiership. Near the end of the season, it was reported by BBC Sport that Wilson had exercised a clause in his contract allowing him to become a free agent.