I've never once referred to the risk-free rate so how is the equity risk premium relevant?

It's implicit in your assumptions.

For the sake of simplicity, let's assume that banks can borrow money at the risk-free rate ("T") and can lend money to home buyers at T+3%.

Over the last century, the equity risk premium has averaged around T+4%.

T happens to be (effectively) zero at the moment but that hasn't always been the case. Over the last century, T has averaged around 3% in nominal terms.

So if you are going to assume average nominal equity returns of 7%, that implies that T will average at 3% over the period (assuming the ERP is constant).

The salient point is that even if we increase the 3% to (say) 4% and decrease the 6.5%, the pension contribition still wins.

Actually, the pension contribution "wins" even in circumstances where the annualised return on the equity portfolio is somewhat less than the weighted average mortgage rate over the period because of the tax relief.

For example, 100 compounded @2% over 30 years comfortably beats 60 compounded @3% over the same period.