prestar vs pedir prestado
English 'borrow' and 'lend' are two verbs. Spanish has prestar for lending and needs a whole phrase, pedir prestado, to borrow.
prestar
To lend — you hand something over temporarily.
Préstame el coche este fin de semana.
Lend me the car this weekend.
The lender is the subject. The borrower is the indirect object.
Me prestó diez euros.
He lent me ten euros.
Money can be lent too. English 'loan' or 'lend'.
Presta atención.
Pay attention.
Prestar atención = to pay attention. Fixed phrase.
pedir prestado
To borrow — literally 'ask to be lent'. Always a phrase, never one verb.
Le pedí prestado el coche.
I borrowed his car.
Literally 'I asked him for the car lent'. The borrower is the subject.
¿Puedo pedirte prestado un bolígrafo?
Can I borrow a pen?
Polite, very common.
Pidieron prestado dinero al banco.
They borrowed money from the bank.
Prestado stays invariable in this phrase. 'Pidieron dinero prestado' is also fine.
Tricky bit
'Voy a prestar tu bolígrafo' means 'I'm going to lend your pen' — to someone else. If you want to borrow it, say 'te pido prestado el bolígrafo'.