The normal maximum stay for a worker in the United States on an H-1B visa is six years, even with extensions. However, there are two limited cirumstances in which you can apply for more time. These include situations where you're:
(If you need an extension of your H-1B stay but haven't yet reached the six-year limit, see "How to Apply for an Extension of Your H-1B Visa".)
If, on top of working on an H-1B visa, you are pursuing an employment-based green card in the first, second, or third preference category, and you would be eligible to adjust status (apply for a green card in the U.S.) but for the fact that you're stuck in line, waiting for an immigrant visa to become available because of per-country limits, you may obtain an extension of your H-1B status beyond the six-year limit.
You'll need to prove that you're truly in line, however, and are the beneficiary of an approved Form I-140 petition filed by your employer, or at least an approved labor certification with a pending I-140.
This extension allowance is highly useful, because long waiting periods have developed for employment-based preference visas, especially for people from China and India, from where many people apply. (Visa availability is all about supply and demand.) No matter which country you're from, however, if your category is backlogged, even if it's the general "worldwide" category, you can make use of this rule.
How long an extension may you receive under this rule? The maximum is three years. If you want that much time, you'll need to not only request it in your extension application, but include a labor condition application (LCA) covering the entire three-year period. If you are given less time, don't panic. You can apply for more than one extension if you're still facing the same per-country visa limitations.
Similar to the first extension exception, there's another one for H-1B workers who have been waiting a long time for a decision on their labor certification application, employment-based visa petition, or adjustment of status (green card) application. If any of these was filed at least 365 days ago, and was filed before you reached the end of your fifth year in H-1B status, you can apply to have your status extended beyond six years.
There is no limit on the number of extensions you can receive under this rule. You are permitted to keep requesting more extensions of one year at a time until the relevant agency makes a decision on your application or petition and you ultimately are approved for a green card.
If you fail to maintain valid H-1B status, or your status expires before you file the extension request, your request will be denied. If your employer hasn't already hired an attorney to help, you'd be wise to consult one for help with this process. The attorney can both figure out your eligibility for an extension and help you with the application process.