I have a battery pack consisting of 4 10 amp-hour 12 volt batteries wired in parallel. We recently bought a 2000 Watt rated HammerDown power inverter to run a 500 watt window air conditioner. The air conditioner is supposed to draw 5.6 amps. But when I connect the AC to the inverter the air conditioner always shuts off as soon as the compressor starts running. I measured the current going to the inverter and as soon as the compressor started it shot up from around .3 Amps a whopping 26 Amps before turning off! Now I understand there is a surge of current needed when starting an appliance but I didn't think it would be this much. I also noted that the voltage dropped a little too (from 13.5 to 12.9 v). Given all that though, I don't understand why the inverter failed to supply the power to the AC. With 40 amp hours shouldn't it be able to provide 40 amps of current at any moment (more than needed for surge)? Another interesting thing to note is that sometimes the inverter would read OVERLOAD after one of these tests.
Your compressor is likely run by an AC induction motor, and they take very large surge currents to start.
Your inverter is rated at 2kW, and no matter how much battery capacity you have it will cut off when it reaches its overcurrent limit. If your mains voltage is 120VAC 40A would be 4080W, well above the rating of your inverter. (Even worse if your mains voltage is 220VAC).
Your inverter can likely handle short surges above rating, but starting an AC compressor is a notoriously hard thing to handle.
John D has answered the inverter overload issue. I'll answer another part.
With 40 amp hours shouldn't it be able to provide 40 amps of current at any moment (more than needed for surge)?
To understand the maximum current from the battery you need to consult the datasheet. 40 Ah is an energy rating (sort of - a better energy measure would be Wh, watt-hours which is V x Ah = 12 x 40 = 480 Wh in your case). The Ah rating is usually measured on a 10-hour discharge so a 40 Ah battery will typically supply 4 A for 10 h. At lower discharge rates the time will be higher than the rating would suggest while at high discharge rates it will be lower. i.e., at 40 A discharge, if the battery can handle it, the discharge time will be considerably less than the 1 h the calculation might suggest.
The 40 Ah rating does not tell you that the battery can actually supply 40 A. It might not or might be able to supply 400 A. Again, the datasheet is your reference.
I also noted that the voltage dropped a little too (from 13.5 to 12.9 V).
Try measuring at the compressor. If it drops more there then your cable is inadequate.
Notes: SI units named after a person have their symbols capitalised but are lowercase when spelled out. 'V' for volt, 'A' for ampere, 'K' for kelvin, 'Ω' (capital omega) for ohm, etc. Meanwhile 'k' is for kilo.
Motors when starting draw from 3x ( soft-start 3 phase type) to 5x typ to 8x with Start-Cap surge current to 12x for high-efficiency BLDC motors. (10x typ)
Your inverter is unable to handle the startup load. It is intended for Blenders, Vacuums and Power Tools and not an air-conditioner compressor which has a much longer startup time.
For industrial use, they may choose a VFD instead of an inverter. This allows the user to choose a voltage a slow voltage ramp with a rising frequency and fixed V/f and thus it is possible to limit the surge current much lower values with high torque, instead of 8x as in your case.