I have only done SCL-IQQ-LPB rather than the other way around but the equivalent situation applies at PUQ for the MPN-PUQ-SCL flights (which I have done): everyone comes off at PUQ, clears immigration, goes through a customs/SAG check (but for hand luggage only) and re-boards along with the domestic PUQ-SCL passengers; at SCL, passengers from MPN are diverted via customs/SAG for their checked luggage to be scanned.
Hope this info helps rather than hinders.