Lookup Filter on Junction Object
Related Account as in the Account on the Opportunity? The problem with a junction object is that the lookup hasn't been committed to the database yet, so there is nothing to filter.
AND(Opportunity__r.AccountID = Contact__r.AccountID
The only other way to go is to try a Workflow rule that pulls down the account Id into a text field, then use that in the lookup filter. However, I think there's some limitations with using text fields? Seems like everytime I try to create one, I expect it to do more than possible, but don't remember exactly.
This page lays out when to use lookup filter vs validation: https://help.salesforce.com/apex/HTViewHelpDoc?id=fields_lookup_filters_notes.htm
You could try a url hack to pre-populate an account field lookup. Save, then use the account id in your contact lookup field.