The Argentina midfielder hit the third and fourth goals after replacing Andres Iniesta as a 63rd-minute substitute in the last-16 first-leg clash, with Cesc Fabregas earlier netting two.
Messi had been out with a hamstring injury since 10 November.
His return comes as the Spanish league leaders prepare for a trip to second-placed Atletico Madrid on Saturday.
Barcelona only lead Atletico on goal difference, with both on 49 points from 18 La Liga matches.
Messi was troubled by injuries in 2013 and the latest of those came when he limped out of a 4-1 win at Real Betis two months ago.
He was initially treated in Barcelona but was then allowed to return to Argentina before Christmas to continue his rehabilitation.
He returned to Spain at the start of January but was not fit enough to figure in the win over Elche on Sunday.
“He came back [from Argentina] and has been working like any other member of the squad,” said Barcelona coach Gerardo Martino.
“Obviously he is lacking a bit of playing time but seeing as we are talking about Leo it is not really an issue.
“He has told me he is feeling fine and that’s why he is in the squad.”