Ignoring in game ramifications, from the rules yeah that was illegal, but from the "that looked like a lateral cause he threw it behind him test" it passes.
It would be nice if football had less insane rule controversies, continuous instant replays and flags and instead had more fun.