The Trail Blazers had forced a 106-106 tie with 1.9 seconds left when Damian Lillard made a 3-point try.
But the Mavs came right back when Ellis dribbled down the court and fired in a pull-up jumper from the top of the key as time expired.
Dirk Nowitzki contributed 28 points, seven assists and six rebounds for Dallas.
Lillard finished with 32 points for the Blazers.
LaMarcus Aldridge chipped in 19 with 13 rebounds.