Goals from Steffen Kienle and Vitalij Lux secured a memorable win for the fourth-tier side at Donaustadion.
Goncalo Paciencia halved the deficit in the 90th minute, but Frankfurt could not find a second goal in the six minutes of added time.
It is the first time the holder has been knocked out in the opening round since 1996, when Kaiserslautern was beaten by Greuther Furth.
The defeat underlines a miserable start to life at the club for head coach Adi Hutter, who took charge after Niko Kovac went to Bayern Munich less than two months after beating them 3-1 in last season's DFB-Pokal final.
Frankfurt was hammered 5-0 by Bayern in the DFL-Supercup last weekend before the defeat to Ulm, which is third in the Regionalliga Sudwest standings.