Mustapha Carayol and Cameron Park scored as Middlesbrough beat Gillingham to reach the third round of the Capital One Cup.
Carayol opened the scoring with a powerful drive beyond Gills keeper Stuart Nelson in the 23rd minute.
Gillingham should have equalised through Danny Kedwell but the striker fired just wide.
The hosts dominated late on but were punished in the final minute when Park clipped the ball into the net.
Gillingham had gone into the game boasting a 100% record in all competitions so far this season.
However, they almost fell behind inside the opening five minutes as Marvin Emnes beat the offside trap, but was denied by Nelson.
Kedwell fired wide for Gillingham and Middlesbrough immediately went straight down the other end to open the scoring as Carayol skipped past two challenges before firing beyond Nelson.
Kedman should have done better when he shot wide from Deon Burton's headed pass before Park broke clear in the 90th minute and chipped the ball over Nelson to secure victory for the Championship side.
Middlesbrough boss Tony Mowbray:
"First half, we were exceptionally good and probably deserved to be more than one up. Second half, we got dragged into a scrappy affair and weren't as fluent. We finished strong though.
"We've got some players now who can make the difference. On nights like tonight, you need to utilise them. Other nights it will be more backs to the wall and you need more soldiers on the pitch than artists. First half, the artists came to the fore and showed their talent.
"The shape worked all right tonight. It was an experiment. When you play shapes that are different from the norm, teams try to figure them out at half-time. It's their [the coach's] job to work out how to stop a team being as fluent as we were first half.
"In the second half, we weren't as fluent but we didn't really look like we were going to concede. Job done."
Sorry, we were unable to load match stats, please try again.