Generally, you are eligible for Medicare after you received social security disability benefits for 24 months. If you receive disability benefits retroactively, you are eligible for Medicare beginning 2 years after the date that the social security administration or a social security judge finds that you were disabled. As an example:

Harry applies for social security benefits on December 1, 2010, claiming he was disabled from a back injury since August 1, 2008. A social security judge finds that Harry is entitled to disability benefits but finds that he was not disabled until September 1, 2010. Harry will receive his disability payments back to September 1, 2010. However, he will have to wait until September 1, 2012 to be eligible for Medicare benefits. 

Same scenario, but the judge decides that Harry was disabled as of August 1, 2008. By the time the judge makes this decision, 2 full years have passed since the date that the judge finds that Harry was disabled. Harry is immediately eligible for Medicare at the time he is awarded social security disability benefits.