Ramprakash began the day 69 not out and batted magnificently for his third Championship century of the season and the 37th of his career, while Kent were indebted to Zimbabwean spinner Paul Strang, whose 6 for 88 came off 27.2 overs and was his second haul of five wickets or more in an innings this season.
Middlesex began the day 134 for 5 - 127 short of victory - and Kent made further inroads when the South African Jacques Kallis and Keith Brown were out in successive overs, with only 23 runs having been added.
Kallis dominated the strike during the first 25 minutes, but was then leg before for 22 to a full-length delivery from Martin McCague. Brown, usually the man for a crisis, swept the first ball he received from Strang and was well caught at long leg by Ed Smith.
Richard Johnson proved the ideal partner for Ramprakash, striking six boundaries in a season's best 33, but fell leg before to Strang, misreading the googly and playing no stroke. Angus Fraser, having shown stout defence, suffered an unfortunate lapse and skyed Strang to deep square leg with Middlesex still 25 short of their target.
A knife-edge situation made for a tense lunch break with Middlesex within 11 runs of victory. Ramprakash, then on 111 - his 167- ball century having including one six and 13 fours - held the key, but he had only the No 11 batsman Phil Tufnell (four not out) for company.
The last-wicket pair had almost made it when Tufnell presented a catch to Trevor Ward at silly mid-off. It was a deflating moment for Ramprakash, but his efforts to engineer an unlikely triumph were nothing short of inspiring.Reuse content