To be eligible for Social Security benefits, you must earn at least 40 "credits." You can earn up to four credits a year, so it takes ten years of work to qualify for Social Security. In 2013, you must earn $1,160 to get one Social Security work credit and $4,640 to get the maximum four credits for the year.
Your benefit is based on the 35 years in which you earned the most money.
If you have fewer than 35 years of earnings, each year with no earnings will be factored in at zero. You can increase your benefit by replacing those zero years, say, by working longer, even if it's just part-time. But don't worry -- no low-earning year will replace a higher-earning year. The benefit isn't based on 35 consecutive years of work, but the highest-earning 35 years. So if you decide to phase into retirement by going part-time, you won't affect your benefit at all if you have 35 years of higher earnings. But if you make more money, your benefit will be adjusted upward, even if you are still working while taking your benefit.
There is a maximum benefit amount you can receive, though it depends on the age you retire. For someone at full retirement age in 2013, the maximum monthly benefit is $2,533. You can estimate your own benefit by using Social Security's online Retirement Estimator
How Benefits Are Factored