Melgarejo was born in Loma Grande District. He started his professional career with Club 12 de Octubre at the age of 19, and later moved to the capital, Asunción, where he represented Club Olimpia and Independiente FBC.
In early June 2011, Melgarejo moved to Portugal after being signed by Primeira Liga club S.L. Benfica, who immediately loaned him to fellow league side F.C. Paços de Ferreira for one season.
Melgarejo scored on his debut with Paços, a 2–1 home win against U.D. Leiria. He also found the net against FC Porto in a 1–1 draw on 25 March 2012, also at home, and finished the campaign as the team's top scorer.
For 2012–13, Benfica manager Jorge Jesus decided to recall Melgarejo and reconvert him into a left back, also immediately placing him as a starter. On 17 September, in spite of initial criticism, his contract was extended until June 2018 with a release clause of €30 million.
Melgarejo spent most of the campaign in the starting eleven, including in the UEFA Europa League final, but was an unused substitute in the season's Portuguese Cup final, with Benfica losing both matches.
In July 2013, it was widely reported that Liverpool had agreed a deal to sign Melgarejo on loan, with a view to making the move permanent at the end of the season, but no transfer took place. Instead, on 2 September, he signed with Russian Premier League club FC Kuban Krasnodar for a €5 million fee.
On 8 February 2016, Melgarejo joined FC Spartak Moscow on a long-term contract.
On 14 November 2012, Melgarejo made his debut for the Paraguay national team, playing the second half of a 3–1 friendly win over Guatemala.
In August 2017, Melgarejo spoke in an interview showing his frustration of not receiving a call up for the national team after 7 years of playing in Europe.Benfica
Taça de Portugal: Runner-up 2012–13
UEFA Europa League: Runner-up 2012–13
Russian Cup: Runner-up 2014–15
Russian Premier League: 2016–17
Russian Super Cup: 2017