There are three electronic components that could be causing the problem - MAP Sensor (inside the carb), Crank Position Sensor (on the front of the crankcase) and the ignition module (under the seat). The 2005 Sportster has some diagnostics that can be read by using the speedometer reset button but it wasn't showing any fault codes. I didn't feel like replacing electronic components based on a guess.
I thought it might be a fuel starvation issue so I pulled the gas tank and removed the petcock so I could clean the fuel filter. The filter had some sand-like crud on it so I washed it out with Dawn and then gas. The bikes running fine now.
The petcock is interesting on that bike. It has 3 positions - off, reserve and main. It was built backwards - so the reserve is actually main and main is reserve. It's also vacuum operated so you can't easily drain the tank without a vacuum pump. That gave me an excuse to buy a Mityvac and play with that a little bit. You could drain the tank by pulling it off the bike and then removing the petcock. That would be a little messy - but I could see doing it with a funnel and a gas can to save the gas your draining out.
HD built in protection to guard against hydrolock on that bike; the petcock with dual redundancy - off position and vacuum operated, carb overflow tubes and a built-in fuel filter to keep crud out of the carb which could cause the float or float needle to stick. The idea is you want gas to flow when the engine runs. In the event of a failure where the the petcock and float stick you want gas to run out of the overflow tubes and not into the cylinders. It's a good design. In this particular area I'd say the HD design comes out ahead compared to a Kawasaki C10 Concours or KZ1000P where there is no off position on the petcock, no fuel filter and no overflow tubes.