Visas are required by all foreigners entering Jordan. These are issued with a minimum of fuss at the border or airport on arrival (JD20). Note that visas are not issued at the King Hussein Bridge if you plan to enter from Israel & the Palestinian Territories. At the airport immigration counters, join the normal immigration lines to get your visa. There are moneychangers adjacent to the counters; ATMs are only available after immigration.
Tourist visas are valid for three months (ie you must enter the country within three months of the date of issue) for stays of up to one month from the date of entry, but can be easily extended for stays of up to three months.
Visas can also be obtained from Jordanian consulates or embassies outside the country. The cost is usually around JD14/28 for a single/multiple entry visa. They are issued within 24 hours and two photos are required. In the Middle East, visas are available from Jordanian embassies in Turkey, Lebanon, Syria, Israel & the Palestinian Territories (avoid this if you wish to travel elsewhere in the region), Egypt, Iraq, Yemen and the Gulf States.
The only reason to apply for a visa from a Jordanian consulate or embassy is if you wish to obtain a multiple-entry visa, as these are not issued at the border, or if you plan to arrive via the King Hussein Bridge.
One exception worth knowing about is that if you arrive in Aqaba by sea from Nuweiba in Egypt (and presumably also by land from Eilat) your visa should be free because Aqaba has been designated as the Aqaba Special Economic Zone Area (ASEZA) set up for free trade. If you plan to stay in Jordan for more than two weeks you have to register with the ASEZA office in Aqaba (rather than the police station). It's also theoretically possible to enter through another border crossing and ask for a special 'Aqaba visa'. Your visa should then be free but you must go straight to Aqaba and register with ASEZA within 48 hours of your arrival in Jordan. Failure to do this will incur the JD10 visa fee and a fine of JD1.500 per day.
If you will be in Jordan for less than 24 hours en route to a third country you can request a free-of-charge transit visa. This also exempts you from the JD5 departure tax but you must leave Jordan within 24 hours of arrival.
A single-entry visa is valid for one month after arrival in Jordan (it used to be two weeks but this changed in June 2005 - check what is written on your visa), after which time you need to register at a police station in order to get the full three months of your visa. Failure to do so will result in a fine of at least JD1.500 per day for every day you have overstayed.
One visa extension of two or three months is easy to obtain, and often in less than 30 minutes. Extensions are technically possible in major provincial capitals such as Aqaba, Irbid and Karak, but are best done in Amman. An extension costs nothing, and no photos are needed. After a stay of three months you may require an HIV test (JD20), though some travellers report that this is sometimes required after only one month. The maximum stay allowed is six months.
If you want another extension, wish to reside in Jordan, or there is something unusual about your visa (eg a curious number of Israeli stamps), you may be sent to the Directorate of Residency & Borders (Map p0005623348; Majed al-Idwans St, Shmeisani, Amman; 8am-3pm Sun-Thu, 8am-1pm Sat) for further checking and paperwork. Take service taxi 6 or 7 to Shmeisani from downtown, from where it's a 15-minute walk. The office is next to the Shmeisani central police station.