The Argentinian struck from close range with six minutes remaining as City came from behind to condemn the Portuguese champions to a rare defeat at the Estadio do Dragao.
The hosts took a 27th-minute lead in the first leg of the last-32 clash through Silvestre Varela but an Alvaro Pereira own goal gifted City an equaliser.
City will now be confident of completing the job at the Etihad Stadium next Wednesday.
Manchester City Roberto Mancini said: “I think that we played a good game. We played very well. In the first half we had three or four chances to score and we were unlucky but in the second half we played very well.’’
Reports had circulated that City striker Balotelli had been the victim of racist chanting from the stands, but Mancini said he was unaware of any incidents.
“I didn’t hear this, sorry,” he said.
Mancini’s men were up against strong opposition in a Porto team which won the Europa League last year and had not been beaten at home in a major competition all season.
Yaya Toure and Mario Balotelli both returned after international duty and suspension respectively while further forward drive came from David Silva and Samir Nasri, with Carlos Tevez back at the club but not making the trip.
It was not all attack as Gareth Barry and Nigel de Jong started in midfield but Toure initially seemed keen to get forward and remind City of what they have badly missed in recent weeks.
Silva beat Maicon with a nice piece of skill and released Toure in the opening minutes but the Brazilian defender got back to deny the African Cup of Nations finalist.
City made a steady start but Gael Clichy was rushed into a clearance as Hulk pressured him inside his own area and Vincent Kompany hacked away after James Rodriguez beat Micah Richards to cross.
Porto had the first serious chance of the game when Rolando saw a header deflected over for a corner by Clichy.
Joao Moutinho then tried his luck from distance but fired wide of the target.
City then had a good spell, forcing Helton to make three saves in quick succession.
The Porto goalkeeper first blocked as Balotelli helped on a free-kick — awarded after Danilo injured himself fouling Toure and was carried off — unconvincingly.
He then did much better to turn a long-range drive from Richards and another attempt from Nasri behind.
Porto responded by applying some pressure themselves with Alvaro Pereira, Hulk and Rodriguez troubling the City defence with dangerous runs.
Toure was booked for bringing down Rodriguez while Hulk appealed in vain for a penalty after going down under a Kompany challenge.
The hosts claimed the lead as Hulk broke down the left and crossed low for Varela, who got ahead of Clichy to turn the ball in from close range.
City had a chance to equalise immediately but Helton again did well to deny Balotelli after the Italian was put through by Nasri.
Porto had another good chance before the break as Lucho Gonzalez struck a fierce shot from a corner but Joleon Lescott blocked before Hulk shot over.
City started the second half well as Richards burst into the box and struck the base of the post with a low drive.
The visitors continued to show attacking intent but benefited from a stroke of luck as they equalised after 55 minutes.
Pereira tried to cut out a Toure cross aimed at Balotelli but the ball struck his shoulder and bounced beyond a wrong-footed Helton into the net.
Porto quickly looked to re-establish their advantage and won a free-kick when Kompany, who was booked, felled Hulk.
De Jong was also shown a yellow card as he rushed to charge down Hulk’s shot too quickly and then Joe Hart needed to make a smart save to deny Porto’s star.
In a flurry of bookings, Barry also had his name taken after a foul on Rodriguez and Nasri joined him after tripping Hulk.
Hulk won and took another free-kick but Hart claimed with ease.
Richards thought he had found a gap as he raced through after exchanging passes with Toure but was flagged offside.
City made a crucial substitution with 12 minutes remaining as Aguero came on to replace Balotelli, who was booed off the field by the home fans.
It was a change which paid off within six minutes as Nasri played in Toure and he pulled back for an unmarked Aguero to calmly side-foot the winner from six yards.
Richards became the sixth City player booked in injury-time but City had earned their advantage.
Subs for Porto: Mangala for Danilo 22, Kleber for Varela 77, Defour for Mangala 89.
Subs for Man City: Aguero for Balotelli 78, Kolarov for Silva 82, Zabaleta for Nasri 88.