Ghostly Prison and similar effects (Propaganda, Windborn Muse, etc.) impose a cost that must be paid when a player declares attackers against you. Specifically, Ghostly Prison reads: 'Creatures can't attack you unless their controller pays 2 for each creature they control that's attacking you.' This is a cost applied at the time of attack declaration (CR 508.1g), not a prevention or redirection of damage.
If the attacking player pays the required mana, the creature is legally declared as an attacker and proceeds through combat normally. Any damage it deals — including to the defending player — counts fully toward commander damage (CR 903.10a requires tracking the 21 cumulative damage a single commander deals to a player over the course of the game).
If the attacking player cannot or chooses not to pay the tax, the creature simply cannot be declared as an attacker at all. In that case, no attack happens and no commander damage is dealt. The tax effect never interacts with damage itself; it only gates whether the attack can be declared.
It is also worth noting that commander damage tracks damage dealt by the commander regardless of how combat damage is assigned or what costs were paid to enable the attack. Effects like double strike (CR 702.4) or trample still apply normally once the attacker is legally declared.
Example: Your opponent controls Thalia, Heretic Cathar (a commander) with power 2. You control Ghostly Prison. On their turn, they pay 2 to attack you with Thalia. Thalia deals 2 combat damage to you. That 2 damage counts toward the 21 commander damage needed to eliminate you from the game.
Unofficial fan resource — not affiliated with or endorsed by Wizards of the Coast. Answers are AI-generated estimates grounded in the Comprehensive Rules and are not a substitute for an official judge. Verify anything match-critical.