Tory Lanez's surprise appearance at Rolling Loud better have been worth it for him, because it's landed him in hot water with prosecutors who are now going after him in court, claiming he violated a court order to stay away from Megan Thee Stallion.
Sources with direct knowledge tell TMZ ... prosecutors have filed a motion to hold Lanez in contempt for violating the restraining order that was issued in his ongoing criminal case.
We're told the prosecutors believe Tory's guest appearance during DaBaby's controversial set at the Miami hip-hop festival last month violated the judge's order, because he got within 100 yards of her.
Our sources say prosecutors have filed legal docs asking the judge to either revoke Tory's bail -- which could land him in jail pending trial -- or at the very least increase his bail.
And, our sources also say prosecutors believe Tory and DaBaby attempted to rush the stage while Megan was performing.
A source close to Tory told us he never saw Meg at the festival nor did he ever get physically close to her.
A hearing on the contempt motion is set for next Thursday.