When you work and pay Social Security taxes, you earn credits toward Social Security benefits. To qualify for Medicare at age 65, you need 40 credits or 10 years of work. You may qualify for Medicare through your own earnings history, your current spouse, former spouse or deceased spouse.