The former Gretna, Dundee United and St Johnstone player suffered cruciate ligament damage during his side's goalless draw at Motherwell on Saturday after landing awkwardly.
And a visit to a specialist today confirmed his worst fears.
Grainger wrote on his Twitter account: "Had some terrible news today about my injury to say im gutted is an understatment [sic] but unfortunately i will miss the rest of the season.
"I need an operation on my knee which means im gonna be out between 6-9 months! lots of kind msgs from footballers and fans means a lot."
Teenager Kevin McHattie came in at left-back for Hearts in their 4-0 defeat by Celtic on Wednesday night.