You can legally transfer the pistol through an FFL dealer in your friend's state of residence, so an FFL dealer in Maine. You or your friend will need to pay the transfer fee which covers the FFL dealer's time for the background check, and you will need to follow all state laws on the way as far as transporting the firearm in a vehicle. Alternatively, you can ship the pistol to an FFL dealer in Maine and your friend can pick it up there after passing the federal background check and paying the transfer fee. The fee is typically between $15 and $30.