Enzo Maresca’s side lost to Leeds last week and Greenwood – on loan at Boro from Elland Road – hit a brilliant free-kick seven minutes from time to lift Michael Carrick’s Boro up to 10th in the table, just two points outside the top six.
Leicester are now only top on goal difference following Ipswich’s win over Swansea.
The Foxes had looked the more likely winners for long spells at the Riverside but could not force a way through Middlesbrough’s organised backline.
There was not much to separate the sides in a hard-fought first half, with both keepers making brilliant saves.
Leicester dominated possession in the opening stages but it was Boro who created the better of the early chances, with Josh Coburn – who bagged a brace in last week’s 3-3 draw at Plymouth – twice going close.
Although the home side did a good job of restricting Leicester, the Foxes did have two good first-half opportunities to break the deadlock.
Maresca’s side were almost gifted an opener when Isaiah Jones’ attempted backpass was intercepted by Kelechi Iheanacho, who stung the hands of home goalkeeper Seny Dieng.
And just after the half-hour mark, Dieng again denied the leaders, making a superb one-handed save to keep out Jannik Vestergaard’s header after a corner from the left.
In the dying seconds of the opening period, it was the turn of Leicester keeper Mads Hermansen. First he got down to his left to tip a low Matt Crooks shot around a post. And from the resulting corner, he clawed out a Dael Fry header that looked destined for the top corner.
Leicester tried to turn the screw in the second half and substitute Abdul Fatawu bounced over a volley from close in after good work down the left from Stephy Mavididi.
Mavididi then had a chance of his own but dragged his left-footed shot wide of the far post, before Iheanacho was gifted an opportunity after a Dieng mistake, only for the keeper to make amends with a fine stop.
Iheanacho beat Dieng with his next chance with just over 10 minutes to play, only to see his delicate chip bounce back off the near post. And moments later, against the run of play, Boro scored what proved to be the winner.
There was initially some anger inside the Riverside when referee Oliver Langford pulled back play for a foul on Greenwood instead of playing the advantage with the home side in the attack and with men over.
But Greenwood lifted himself off the deck to curl home a beautiful free-kick into Hermansen’s top corner.