You do get to claim this tax as a credit against your US tax on the gain (if you owned the property individually or through a fideicomiso) which does avoid double taxation.
If you own the property in your individual name or through a fideicomiso, you can utilize or US tax purposes the $500,000 gain exemption if married (or $250,000 if you are single) on sale if you occupied it for 2 out of the last five years as your primary residence. The primary residence gain exclusion has much tougher requirements under Mexican tax law, but those rules do not apply for US tax purposes.
Another problem arises when you held your Mexican real estate through a Mexican corporation and you or other US taxpayers owned more than 50% of that corporation. Due to that manner of ownership, it could prevent you from claiming the foreign tax credit for the Mexican capital gains taxes you paid and cause you to pay high US taxes on the gain when it is distributed from your corporation which is often double taxation.
What is the solution? When you purchase property in a Mexican corporation make certain it is the corporation known as SRL de CV. That Mexican entity (and none other) is eligible or US tax purposes to elect flow through status (for US tax purposes only- this election does not affect the Mexican taxes) which means any gains on sales will be taxed at US capital gains rates (if you held the property for more than a year) and you can offset that tax with the Mexican gains tax you paid on sale. It totally avoids any possibility of double taxation. Ask us how.