Foster made his debut for Aberdeen aged 17 on 10 May 2003 in a Scottish Premier League match against Partick Thistle, coming on as a substitute for Darren Mackie. He scored his first goal for the club almost exactly a year later during a 2–1 league win over Dundee on 15 May 2004. Foster became a first team regular under Jimmy Calderwood and signed a two-year contract extension on 31 July 2007. Although naturally a right winger, Foster made significant progress by playing in the left back position during the 2007–08 season, impressing with his man-marking performances when Aberdeen's first-choice left back Richie Byrne was injured. On 20 September 2007, he made his European debut in the first leg of Aberdeen's UEFA Cupfirst round tie against Dnipro, coming on as a 72nd-minute substitute for Jackie McNamara as the game ended 0–0. Foster started at left back in the return match in Ukraine on 4 October and provided the assist for Darren Mackie's opening goal, sending in the cross for the striker to head home from close range. Despite Dnipro salvaging a 1–1 draw, Aberdeen progressed to the group stages of the tournament on away goals. On 20 December, Foster scored the first European goal of his career in Aberdeen's 4–0 UEFA Cup group stage win over Copenhagen. The result put the Dons through to the last 32, where they lost 7–3 on aggregate to Bayern Munich; drawing the first leg 2–2 at Pittodrie and losing 5–1 in the second leg at the Allianz Arena. In February 2009, Foster was involved in a training ground bust up with Calderwood which led to him being omitted from the Aberdeen squad to face Dundee United on 21 February, after he called the then Dons manager "stupid". On Foster's return to Aberdeen, he was appointed as Paul Hartley's successor as Aberdeen captain for the 2011–12 season.
Rangers (loan)
On 31 August 2010, Foster moved on a season-long loan to SPL champions Rangers, with Gers striker Andrius Velička moving in the opposite direction. He was given the number 12 shirt and made his Rangers debut on 11 September, coming on as a substitute for Kirk Broadfoot in a 2–1 victory over Hamilton Accies. Foster made his first Rangers start on 20 October in a Champions League group stage match against Valencia at Ibrox, where he was selected as man of the match despite missing an open goal. Many of Foster's Rangers appearances came in the Champions League and Europa League. He played at right back in a 2–2 draw with Sporting Clube de Portugal in the second leg of the Europa League last 32, as Rangers won with the away goal rule coming into play. He was involved in an Old Firm match against Celtic on 2 March 2011, where the 1–0 defeat was overshadowed by scenes at the conclusion of the match. Foster's European run continued in the last 16 first leg against PSV Eindhoven on 10 March, which ended 0–0. He finished the SPL season with a winner's medal, having made enough appearances to contribute to Rangers title success. However he was cup-tied for their victorious 2010–11 Scottish League Cup campaign after being an unused substitute for Aberdeen against Alloa Athletic earlier in the season.
Bristol City
On 6 January 2012 he signed for Championship side Bristol City on a two and a half-year contract for an undisclosed fee.
Rangers
Foster signed for Rangers on a two-year contract in June 2013.
On 19 August 2016, Foster signed for St Johnstone, agreeing a contract until the end of the 2016–17 season. He scored his first goal for St Johnstone against Inverness Caledonian Thistle on 27 August 2016. In April 2017, Foster brought St Johnstone in to disrepute after becoming involved in an on-pitch brawl with teammate Danny Swanson. Both players were suspended by the club and were subsequently fined four weeks' wages. In February 2019, Foster signed an extension to his contract with St Johnstone, which was due to run until the summer of 2020. In August 2019 Foster was involved in an incident with manager Tommy Wright on the training pitch and was dropped from the first-team.
Return to Ross County
Foster left St Johnstone in August 2019 and signed a one-year contract with Ross County. On 25 May 2020, Foster was released from his contract criticising the chairman for not taking advantage of the governments furlough scheme calling it "morally shocking".
Partick Thistle
After leaving Ross County, Foster signed a one year deal with Scottish League One side Partick Thistle.
International career
Foster was selected by the Scotland national under-21 football team. He was selected for the full Scotland squad in February 2012, but he did not play in the friendly with Slovenia. Foster said in November 2018 that he was disappointed that he had not been recalled, given the lack of options in his preferred position.