A public key is used to encrypt and a
separate, different private key to decrypt the
message.
Each party involved generates a key pair.
Each party publishes their public key. This is made widely
known to all potential communication partners.
Each party secures their private key, which must remain
secret.
Assuming A desires to send a message to B, A first encrypts the
message using B's public key.
B can decrypt the message using its private key. Since no one
else knows B's private key, this is absolutely secure -- no one
else can decrypt it.
There still remain difficult problems of authentication of
public keys, compromised keys, bogus & out of date keys.
Further, Public Key encryption is very, very slow compared to
single key systems.
A very useful and common way of using public key cryptography
is as a means of establishing/distributing secret keys for
conventional single key cryptography, see later.