The seller pays the Realtor!
The seller’s apparently had a contract with the Realtor who actually showed the property and handled the buyers negotiations. Then the buyer introduces their Realtor into the picture. In most states this case is clear....whoever show’s the property and subsequently gets the contracts signed has fulfilled their contract obligations in total and is entitled to the commission.