A passport is a citizenship document. Possession of a passport from a particular country defines the traveler as a citizen of that country.
National governments are the issuing authority for passports. In most cases, any citizen of a particular nation may possess a passport, but some countries grant passports to only a select few.
A visa is an ink stamp, usually stamped directly in the passport, authorizing a person from another country to visit the country issuing the visa. Visas can be valid from days to years.
Visas are issued by the consular staff of the destination country. It can take anywhere from hours to months for the consulate to issue the visa.
In some cases, visas are not required because of an agreement between two governments. For example, an American citizen flying into Hong Kong is not required to apply for a visa in advance. A temporary visitor's visa will be automatically issued to American travelers who arrive without a different type of visa.
In some cases, if you are flying through a country and wish to stay for a few days, a transit visa can be issued. These visas are usually valid for a few days.