Allow me to address the Government Tax Lien. For this purpose, I am going to assume that this is a Federal Income tax lien placed by the Federal government. If this is not the case, my answer is not valid.
For a federal tax lien, one should not close on the property unless the IRS agrees to discharge the lien. If they stand in a position of no value to their lien (i.e. they stand behind previous mortgages with balances due in excess of the equity in the property), the IRS will go through a process to releast its lien. To get a start on this process, see IRS Publication 4235.
Marty Davidoff, email@example.com, 732-274-1600. This answer is provided for general information only. You should seek advice from an attorney or tax professional.
Assuming all was done properly (which is not even close to a safe assumption, and all inferior lienholders properly joined and served in the foreclosure, all inferior liens would be extinguished. The first mortgagee foreclosure would also eliminate its lien, and the amount of the debt vs the sale price is not material unless the sale price was grossly insuffient relating to the value of the property.
You don't say what kind of government tax lien you're asking about - is that property tax, a federal tax lien, state sales tax or what ? It matters as to what the effect of all this is.
Please note that the above is not intended as legal advice, it is for educational purposes only. No attorney-client relationship is created or is intended to be created hereby. You should contact a local attorney to discuss and to obtain legal advice.
The lenders that came on board before the IRS put a lien on will get paid first. The taxes will be paid next. This is where the IRS releasing the lien comes into play. If there will not be enough to cover the tax debt in full, they would need to discharge the lien on the property.