Gavranović began his career with AS Vezia, before he was scouted by Team Ticino U18, the youth academy ofFC Lugano.[6] In the 2006–07 season, he played his first professional games in theSwiss Challenge League for FC Lugano. In his second season he scored eight goals in 21 games. In the summer of 2008 he signed forYverdon-Sport and scored another eight goals in only 20 games. For the 2008–09 season, he moved toNeuchâtel Xamax.[7]
After a successful start atNeuchâtel Xamax having scored eight goals in 17 games,[8] Gavranović left his team to sign forSchalke 04 on 1 February 2010.[9] He scored a vital goal for Schalke 04 in the Round of 16 in theChampions League againstValencia, which led his team to a 4–2 victory and a place in the quarter-finals.[10] Gavranović joined fellowBundesliga sideMainz on a season-long loan deal on 31 August 2011.[11] Mainz reportedly paid €200,000 to secure his services and the loan included a deal for a permanent transfer worth €1.5 million.[12]
After only making five appearances during his loan spell, Gavranović returned to Schalke at which point he agreed to cancel his contract in May 2012 and moved on a free transfer toFC Zürich in the summer.[13] He made his debut for Zürich on 15 July 2012, and scored his first goal from the penalty spot in the same match, a 1–1 draw withFC Luzern.[14]
Gavranović scored Zürich's winning goal against reigning championsFC Basel on 11 August 2013 in the fifth round of the Swiss Super League.[15] He scored Zürich's first goal as the club twice came from behind to defeat FC Stade Lausanne Ouchy 3-2 in the second round of theSwiss Cup on 15 September.[16] On 24 November, Gavranović netted twice in the second half of Zürich'sSuper League clash withFC Sion, inspiring his side to a 4–1 victory.[17]
In theZürich Derby match againstGrasshoppers on 1 March 2014, Gavranović scored a goal in either half to give Zürich a 3-1 win.[18] On 21 April 2014, Gavranović scored twice in extra-time to lead Zürich to a 2–0 victory over Basel in thefinal of the Swiss Cup.[19]
After suffering a knee injury in training at theWorld Cup, Gavranović was sidelined for the rest of 2014.[20]
On 18 January 2016, Gavranović moved toHNK Rijeka in Croatia. He signed a2+1⁄2-year contract with the club and joined their pre-season training camp inDubai.[21] Gavranović scored on his official club début on 12 February 2016, converting a cross byRoman Bezjak in the 25th minute to double Rijeka's lead againstLokomotiva.[22] In two years with the club Gavranović scored 40 goals in 80 appearances.
On 5 January 2018, Gavranović joinedDinamo Zagreb as part of player exchange deal involvingDomagoj Pavičić andLuka Capan. He signed a three-year contract with the club and selected the number 11 jersey. With a move to the new club and a successful spring season, Gavranović was determined to secure a place inSwitzerland's squad for the2018 FIFA World Cup in Russia.[23] During his official presentation in Zagreb Gavranović revealed that all of his family members are Dinamo supporters and since the early age he was also encouraged to support the club.[24]
He scored his first goal for the club in a 1–0 win overSlaven Belupo on 4 March. On 7 March, he scored against his former clubRijeka, but Dinamo would go on to lose the match 4–1. He scored again in a 2–0 win overRudeš on 17 March[25] and then scored againstIstra 1961 in a 4–0 away win on 8 April.[26] Gavranović scored twice in a 2–1 away win over rivalsHajduk Split, which moved Dinamo closer to securing a 19th league title.[27]
He was released from Dinamo at the end of his contract on 30 July 2020. However, he returned to the club just three weeks later due to injury of club's first strikerBruno Petković.[28] On 17 October, he scored his first hat-trick for Dinamo as they defeatedGorica 3–2.[29]
Gavranović representedSwitzerland on U-21 level in 14 games and scored three goals. On 26 March 2011, he madesenior team debut in the 0–0 draw withBulgaria in aEuro 2012qualifier.[30] His first goals arrived in a brace scored in a 4–2friendly win overCroatia on 15 August 2012.[31] Gavranović was named in thefinal 23-man squad for theWorld Cup in Brazil on 13 May 2014.[32] On 29 June, he sustained a serious knee injury in training, ruling him out for the rest of the World Cup and until early 2015.[33] Gavranović was named in managerVladimir Petković's23-man Swiss squad for the2018 FIFA World Cup in Russia.[34] He played his first ever World Cup match in the secondGroup E match versusSerbia, entering at the start of the second half and giving an injury time assist which was finished byXherdan Shaqiri for a 2–1 comeback win.[35] Gavranović was named in Petković's26-man squad for theUEFA Euro 2020.[36] On 28 June 2021, he was substituted for Shaqiri in the 73rd minute of theRound of 16 match againstFrance. He scored Switzerland's third goal, tying the score at 3–3. Afterextra time and apenalty shoot-out, Switzerland won 5–4 (with Gavranović successfully converting hispenalty) and qualified for thequarter-finals.[37] That was the first time since the1938 FIFA World Cup that Switzerland progressed past a knockout round of a major tournament, and the first time since the1954 FIFA World Cup that they progressed to the quarter-finals of a major tournament.[38]
On 15 September 2022, Gavranović announced his retirement from the Swiss national team,[39] after eleven years and 41 appearances in the senior team. His last appearance was thus on 5 June 2022, in a 0–4 defeat toPortugal in theUEFA Nations League.