Let's say that in year A I had a medical insurance plan without an associated health savings account, and incurred some medical expenses (co-pays, deductibles). I didn't pay them that year; they may even have gone to collection. In year B, I'm covered by a different medical insurance plan with an HSA. Can I use the HSA to pay the bills from year A? Or are the only eligible expenses incurred after the HSA plan's plan year begins? Or, worse, can I only pay a particular expense using money that was contributed before that expense was incurred?
According to the instructions for IRS Form 8889,
Expenses incurred before you establish your HSA are not qualified medical expenses. If, under the last-month rule, you are considered to be an eligible individual for the entire year for determining the contribution amount, only those expenses incurred after you actually establish your HSA are qualified medical expenses.
Accordingly, your medical expenses from year A are not considered "qualified medical expenses" and you should not use funds in your HSA to pay them unless you would like to pay taxes on the distributed funds and a 20% penalty.
Publication 969 states very clearly on page 9:
How you report your distributions depends on whether or not you use the distribution for qualified medical expenses (defined earlier). If you use a distribution from your HSA for qualified medical expenses, you do not pay tax on the distribution but you have to report the distribution on Form 8889.
There is nothing about the timing of contributions versus distributions. As long as the distribution is for a qualified medical expense, the distribution will not be included in gross income and not subject to penalty regardless of how much money you had in your HSA when you incurred the medical expense.
As the answer from Guest5 noted, any expense you have before the HSA is established is not considered a qualified medical expense for an HSA distribution.
However, it is important to note that since you now have the HSA established, any medical expense you have from this point on is a qualified medical expense, even if you don't take an HSA distribution for it right away.
For example, let's say that you have a medical expense this year, but you don't take an HSA distribution to reimburse yourself right away. (Maybe it is because you don't have enough money in your HSA to reimburse yourself at this time.) You can reimburse yourself in the future for this expense. As long as you had an HSA in place when the expense was incurred, it doesn't matter if you wait to take the distribution.
Unfortunately you can't use your HSA to pay for expenses in year A. Qualified medical expenses for an HSA must occur after the date the HSA account was established. (Established typically means the date the account was opened in your name.)
The other answers already mostly answered your other questions, but I want to really hit home some particular points that many people may not realize:
The most important thing to do when you are eligible to have an HSA account, is to open an HSA account ASAP.
This is true even if you don't put any money in it and you leave it empty for years. The reason is that once the account is established, all qualified medical expenses that occur after that date are eligible for distributions, even if you wait years before you fund your HSA account.
The second most important thing to do is to keep track of all out of pocket medical expenses you incur after you open the HSA account.
All you need is a simple spreadsheet and a place to store your receipts. Once you have the account and are tracking expenses, now you can put money into your HSA and take it out whenever you'd like. (With limits- you can't put in more than the contribution limit for a single tax year, and you can't take out more than your eligible expenses to date.)
Helpful Tip: Many people don't fund their HSA because they can't afford to set aside extra money to do so. Fortunately, you don't have to. For example, suppose you have some dental work and it costs you $500. Once you get the bill, before you pay it, put the $500 into your HSA account. The next day, take the $500 back out and pay your dental bill with it. Most HSA accounts will give you a debit card to make this even easier to pay the bill. By putting the money into your HSA for 1 day you just received a $500 tax deduction. Alternatively you can always pay out of pocket like you normally would, track your receipts, and wait until the end of the year (or up until April 15 of the next year). I like this option because I can pay all of my medical bills with a credit card and get cash back. Then at the end of the year, I add up the expenses, deposit that much into my HSA, and if I'd rather put that money somewhere else I just pull it out the next day. If you decide you don't need the money right away that's even better since you can leave it in the HSA account and invest it. Like a Roth account, you don't pay tax on the growth you achieve inside of an HSA.
Another Tip: if your employer offers the service of automatically making deposits into your HSA by reducing your paycheck, you should definitely try to do that if you can afford it, rather than manually making contributions as I described in the previous tip. When your employer makes the contributions for you, your wages are reduced by that amount on your W2, so you end up saving an additional 7% in FICA taxes.