Is it illegal to buy a handgun from a friend, if we're both 18?
If you are both residents of Minnesota, the answer is no. It is not illegal. In fact, according to MN state law, outside of a municipality, the age limit is 14. Within a municipality, the age limit is 18. HOWEVER, the sale of a firearm to a person under the age of 18, even by private parties, would, in most cases be against Federal law.
It would be legal only if he gave them to me as a gift right?
No, that is not correct. It would be legal for him to either sell you the guns or to give them to you as a gift, assuming that your friend does not have a Federal Firearms (dealers) License.
No. There is no such thing as a loop-hole, that is a myth made up by the Brady Campaign. Your actions would be legal, period, no loop-hole.
If I do buy them, would it be illegal for me to have them at my home?
No.
I would like any advice on legally owning a pistol in Minnesota for an 18yr old.
Read the statute for yourself:
https://webrh12.revisor.leg.state.mn.us/statutes/?id=609.66
What is an illegal pistol? One that is used in a crime obviously, but what else?
A pistol used in a crime may not be illegal. It would only be illegal if you took possession of it, knowing that it was used in a crime in an attempt to hide evidence during an investigation. A stolen pistol would be illegal if you bought it knowing that it was stolen. A fully-automatic pistol, without an NFA license is illegal. A silencer for the pistol, without the NFA license would be illegal. A pistol which has had the serial number altered or removed would be illegal. A pistol purchased from an out of state source, without going through a MN FFL would be illegal. A pistol that was manufactured by someone without a manufacturer's license, and then transferred to another party would be illegal. I think that is about it.
Your standard, ordinary pistol, bought from standard, ordinary Joe citizen is perfectly legal in MN.
Now, handgun ammunition, you are also going to have to buy privately. You can not buy ammunition from a dealer for use in a handgun until you are 21. As long as no false statements are made to the dealer regarding the purchase of the handgun ammunition, anyone over 21 can buy it for you, with your money and give it to you. It is only a crime if that person makes a false statement to the dealer. That is Federal Law.