X will relocate from San Francisco to Austin, Elon Musk announced Tuesday on the social media platform.
His rocket company, SpaceX, will also move to Texas.
Musk said a new law signed by California Gov. Gavin Newsom on Monday was "the final straw."
"Because of this law and the many others that preceded it, attacking both families and companies, SpaceX will now move its HQ from Hawthrone, California to Starbase, Texas," Musk tweeted.
The law aims to protect students from having their gender identity or sexual orientation revealed to their parents against their will.
"I did make it clear to Governor Newsom about a year ago that laws of this nature would force families and companies to leave California to protect their children," Musk said.
Musk moved his electric car company, Tesla, to Austin in 2022.