However, Viana was unable to cement a starting XI position at Newcastle United, and returned to Sporting on loan. In his return he found his old form and enjoyed a successful spell, even helping the Lions to the campaign's UEFA Cupfinal.
At the start of 2005–06, Viana moved to Valencia CF, again on loan. In March 2006, reports stated that he had been signed on a permanent deal for £1.5 million. During his first season he struggled to claim a first-team spot, facing tough competition from the likes of David Albelda and Rubén Baraja, manager Quique Sánchez Flores' preferred duo; still, he featured in 19 league games, and displayed some flashes of talent that allowed him to preserve his place in the Portugal national squad. In a bid to secure first-team football, Viana decided to join fellow La Liga side CA Osasuna on loan, on 13 July 2007. However, a serious injury during pre-season forced him out for four months. After recovering, he still featured in all of the last three matches, helping to a narrow escape from relegation. In 2008–09, Viana took no part in manager Unai Emery's plans, being restricted to four UEFA Cup matches and two appearances in the Copa del Rey.
Braga
On 31 July 2009, Viana was loaned to S.C. Braga for one season, thus returning to Portugal after three years. As the Minho club led the league in its early stages, he scored his first goals upon returning to his country, hitting twice in a 3–1 home win against C.F. Os Belenenses on 30 August. On 31 October, he again found the net, from a stunning free kick against S.L. Benfica in a 2–0 home triumph where he received player of the match accolades. Braga eventually finished in a best-ever second place, losing the title to precisely this team, in the last matchday, with the player appearing in 28 matches. In the 2010–11 season, under the same manager, Domingos Paciência, Viana regained his starting position over Aguiar, whom eventually left the club. On 6 March 2011, again from a direct free kick and against Benfica, he equalized for the hosts, in an eventual 2–1 home win; he also appeared in nine games in Braga's UEFA Europa League runner-up run. On 27 November 2011, in a game against FC Porto, Viana displayed a white T-shirt with the words 'Gary – Rest In Peace', in a tribute to Speed, who had committed suicide earlier that day.
Al Ahli / Al-Wasl
On 5 June 2013, Al Ahli Club from Dubai announced the signing of Viana effective as of 1 July, when his contract with Braga expired. He made his debut on 30 August in the year's Arabian Gulf Super Cup at the Mohammed Bin Zayed Stadium, a penalty shootout victory after a goalless draw against Al Ain FC; his performance was described as "quiet" by The National, who attributed it to his unfamiliarity with the heat of the Middle Eastern summer. He totalled 39 appearances and three goals across his first season, helping the team conquer a domestic treble after adding the UAE Arabian Gulf League and the UAE League Cup. Viana agreed to a deal with Al-Wasl F.C. of the same city and league, but the transfer was one of several declared void by the UAE Football Association for missing 3 October 2014 deadline. It was completed the following 19 January. After leaving the club, he retired at age 33 on 13 October 2016, being appointed director of football at Belenenses in May 2017 but leaving his post six months later.