President Trump took to Twitter Thursday to accuse the social media platform of trying to silence prominent conservatives through a “discriminatory and illegal practice” and appeared to threaten an investigation of the company.

For months, Republicans have alleged that they are the victims of what they call “shadow banning,” meaning their tweets are secretly hidden from users, limiting their reach. A report in Vice News on Wednesday further fueled those fears, as some search results on Twitter didn’t seem to reveal the accounts for Republican National Committee Chairwoman Ronna McDaniel and several other party members, although the tool appeared to work well for finding Democrats’ accounts.

Twitter said that some recent changes to its search algorithm were to blame and that it was working to resolve the problem. But the report still drew a sharp rebuke Thursday from Twitter’s most prominent Republican user.

“Twitter ‘SHADOW BANNING’ prominent Republicans. Not good,” Trump wrote to his 53 million followers. “We will look into this discriminatory and illegal practice at once! Many complaints.”

A Twitter spokesman declined to comment on the president’s tweet. The social media company has said it is aware that some accounts are not automatically populating in the search box and is addressing the issue.

A day earlier, Kayvon Beykpour, head of product for Twitter, emphasized that the platform was not targeting Republicans and was working to alter its use of “behavior signals” that inform its search results. Twitter has been tinkering with the guts of its platform to promote healthy conversation on a site that sometimes harbors political vitriol or abusive content.

“To be clear, our behavioral ranking doesn’t make judgments based on political views or the substance of tweets,” Beykpour said.

The president’s tweet Thursday could create new political headaches for Twitter and its tech peers in Silicon Valley, which have faced months of accusations from the highest echelons of the Republican Party that they are biased against conservatives. Members of Congress have brought major tech company executives to Capitol Hill to address allegations of anti-conservative bias, and some GOP lawmakers even threatened regulation of the industry at a hearing this month.

“Our success as a company depends on making Twitter a safe space for free expression,” said Nick Pickles, a policy aide who testified on behalf of Twitter at the hearing.

In this latest controversy, searches on Twitter’s upper right-hand search bar for prominent conservatives such as McDaniel did not automatically list their official accounts, but those right-leaning accounts did appear if users clicked through to the site’s fuller search page.

The extent of the issue is unclear, however, given the fact that Twitter is likely to auto-suggest accounts that users already follow or might be inclined to like.

Despite Twitter’s explanations, McDaniel and other Republicans still castigated the company and claimed its practices amounted to censorship.

“The notion that social media companies would suppress certain political points of view should concern every American,” McDaniel said Wednesday. “Twitter owes the public answers to what’s really going on.”

Donald Trump Jr., the president’s eldest son, also weighed in, sending a tweet Wednesday that said: “So now @Twitter is censoring @GOPChairwoman? Enough is enough with this crap.”

In the past, Twitter has admitted mistakes, even apologizing after an incident last year in which it initially banned a GOP congresswoman from promoting a tweeted video that discussed abortion. But the company has stressed repeatedly that it applies its policies even-handedly.

Meanwhile, Twitter chief executive Jack Dorsey has sought to defuse tensions with conservatives through a series of private gatherings with right-leaning media and political leaders. His trip to the nation’s capital in June, for example, included a dinner with Mercedes Schlapp, one of Trump’s top aides, and Greta Van Susteren, a former Fox News host, sources previously told The Post. Some in attendance told Dorsey that they felt conservatives had been painted in a negative light on the site’s Moments feature, which tracks national stories and issues. Others raised concerns about shadow banning.

But the complaints are hardly bound to die down as the midterm election draws nearer. Already, the charges of anti-conservative bias have made their way into some Republicans’ campaign pitches to voters. House Majority Leader Kevin McCarthy (R-Calif.), who is angling to become speaker of the House next year, has run ads on Facebook that fundraise around allegations of anti-conservative bias on social media.