Texas Gov. Greg Abbott signed a bill Thursday aiming to allow residents to sue social-media companies if their content or accounts are banned from their platforms, a move that comes as similar legislation in Florida remains in legal limbo after a federal judge’s ruling.

Mr. Abbott, a Republican, said House Bill 20 would prevent companies from banning users based on their political viewpoints and allow residents in the state to sue the companies to reinstate accounts deemed to have been unfairly removed. The legislation targets platforms with at least 50 million monthly users in the U.S, which would include those such as Twitter Inc. , Facebook Inc. , and Google’s YouTube among others. 

Social-media platforms have said they don’t discriminate based on users’ political views but enforce rules on content or users violating their terms of service. Such rules on platforms could include misinformation about the Covid-19 disease, incitements to violence or promotion of illegal activities, among other things.

“There is a dangerous movement by some social media companies to silence conservative ideas and values,” Mr. Abbott said in a live video recorded on Facebook. “This is wrong and we will not allow it in Texas.”

A Twitter representative declined to comment. Facebook and Google didn’t immediately respond to requests for comment.  

“This law is going to put more hate speech, scams, terrorist content and misinformation online, when most people want a safer, healthier Internet,” said Adam Kovacevich, chief executive of Chamber of Progress, a left-leaning tech policy group launched earlier this year.

The legislation, which would go into effect in December, marks the latest attempt within statehouses around the country to rein in the behavior of technology companies. But it also is likely to face similar hurdles to enforcement as a bill signed by Florida Gov. Ron DeSantis, a Republican, in May.

The Florida bill restricted tech platforms from banning Florida political candidates and assessed penalties for violating that rule. It also required companies to be transparent about their content-moderation practices and notify users of policy changes.

A federal judge in Florida blocked enforcement of key parts of the legislation a month later, on grounds that it likely violated the First Amendment and was in conflict with federal law.

Section 230 of the Communications Decency Act of 1996 established that companies aren’t liable for harmful content that a user may post and that they can remove content deemed objectionable if acting in good faith. However, some policy makers say tech companies have too much control over what information people view.

Write to Bowdeya Tweh at bowdeya.tweh@wsj.com