Just curious if its possible to stay overnight at Amman airport. My plane will arrive at midnight and by the time that I clear customs etc it wil be about 1.00 am. I was planning on getting a nights accomodation in Madaba but as I plan to leave first thing for Petra wsa thinking that instead I should just sleep at the airport then first thing in the morning make my way to Petra. However, is this at all possible to sleep somewhere at the airport then get a bus into Amman or Madaba and then from there simply get another bus to Petra. Any advice that you can give will be appreciated.

I don'tg actually think this is workable. The problem is that once you pick up your luggage is no real space to sit in and when re-entering the airport you canjnot enter the actual check-in area without a ticket. There are a couple of seats and a small bar before check-in, but no real place to spend the night unless you want to sit in an uncomfortable airport chair all night. I had to wait there once for 3 hours for a connecting flight check-in to open and found even that very uncomfortable.
However there is an airport hotel which you might consider instead.

The airport operates around the clock and security is very low-key. There are seats in the arrival hall for people who await arriving passengers. There are also a couple of benches outside near the taxi and bus rank. Thirdly, you can walk over to the departure hall, where there are more rows of seats in the public waiting area (before security check and check-in counters). Nobody will bother you if you spend a few hours there, and chances are they won't even care if you lie down and sleep as long as you don't unpack a pillow and roll out a sleeping bag! It won't be a very comfortable night, though.
By 5 a.m. or so you can already take the airport express bus into town and work your way towards the Petra bus.
Amman airport really isn't user friendly. All the seats are metal and uncomfortable. Get a few hours sleep in a hotel and the King's Highway bus from Madaba the next day. Seeing Petra for eight hours or so on no sleep is a waste of time and money.

This is the only hotel near the airport (about 1km from the terminal):
http://www.goldentulipairportamman.com
But it is not on any public bus routes, and unless you have your own car it's more hassle than it's worth. Madaba is only 18km from the airport (nearer than Amman) - arrange with a Madaba hotel to be picked up and taken directly there, then ask them to arrange a seat for you on the 10am Madaba-Kings Highway-Petra bus next morning. Best option:
http://www.mariamhotel.com
I agree with RuffGyder's suggestion re Madaba and the Mariam Hotel. We stayed at Mariam twice and thoroughly enjoyed it both times - the place is clean as a whistle, well-run, very friendly, professional and organized. And it's not expensive either.
We also took the King's Highway bus to Wadi Musa and enjoyed that too. The bus leaves from outside the front door of the Mariam Hotel so is very convenient. The hotel will book your seats on the bus - very easy.

BTW - and for any other Royal Jordanian passenger reading this - I flew Royal Jordanian Airways in 2003 and the hotel that ruffgyder refers to: http://www.goldentulipairportamman.com: had a 'relationship' with RJA. I got the RJA transfer bus to the hotel and back to the airport with no additional cost. I just had to show my boarding pass. I got a shower and a meal - had to pay for the meal which wasn't too bad since I needed something different to the traditional Middle Eastern fare I had been on for 6 weeks. Of course, with the current economic difficulties for the travel industry, there may now be a charge OR RJA no longer has a relationship with the hotel since it was rebranded with Golden Tulip. As I have said elsewhere, you don't know if you don't ask so check with the RJA transfer desk at the QAIA OR ask your travel agent to investigate if you haven't started travelling yet.