DALLAS — Aside from being great political theater, Ted Cruz’s stunning victory in the Texas Senate battle this week offers a few instructive lessons about the role of outside money in the Citizens United era.

Ted Cruz (Brett Coomer/Associated Press)

To be sure, Cruz benefited from endorsements by Sarah Palin, Rick Santorum and other tea party favorites, as well as organizational legwork from conservative groups.

But a closer look at spending in the race may explain why so many in the Texas news corps regarded the outcome as an upset, and more importantly, why Citizens United supporters in the GOP may find outside spending the wild card in intra-party fights.

Texas Lt. Gov. David Dewhurst was the favorite coming out of a crowded field of candidates in the May primary. With a campaign war chest more than double the size of lesser-known Cruz, he was positioned to dominate the runoff.

Money continued to come in during the long slog toward the primary runoff. As of mid-July, Dewhurst raised and spent more than $19 million, while Cruz raised and spent almost $8 million, according to campaign figures.

Dewhurst not only led, but had the most money from two of the most influential industries in the Lone Star State: the energy sector and financial services, according to Center for Responsive Politics data.

With endorsements from Gov. Rick Perry and other party figures, that usually adds up to victory on Election Day. That explains why Dewhurst was the presumptive favorite going into the two-way race.

But this contest was unique because it drew so much outside money to a GOP primary contest in an already flush red state.

As a matter of fact, the 2012 Texas Senate contest drew more outside funding than all but the presidential contest this year, according to the Center for Responsive Politics.

Cruz got the lion’s share of money from those outside groups.

Still, even as Cruz gained steam in polls prior to the runoff, some Texas pundits seemed slow to realize the significance of the outside support.

Fort Worth called Cruz’s victory a “Texas stunner.”

In San Antonio, it was labeled a “slap at the status quo.”

And in Austin, it was a “GOP upset.’’

Although outside groups spent about $5 million each against the two candidates, much more outside money was spent in support of Cruz. According to CRP data, $2.8 million was spent by outside groups to support Cruz, compared to $684,871 for Dewhurst.

If anything was a predictor of the outcome of this contest, it was those numbers.

Lori Stahl covers politics and culture in Texas. Follow her on Twitter @LoriStahl.