 -- The White House's social media director violated federal law by posting a tweet calling for supporters of President Donald Trump to defeat an incumbent congressman.

Dan Scavino Jr. posted a tweet against Rep. Justin Amash, R-Michigan, in April and it has now been revealed that he was issued a warning letter by the Office of the Special Counsel in response.

In the tweet, which he posted on his personal verified Twitter account, Scavino wrote: ".@realDonaldTrump is bringing auto plants & jobs back to Michigan. @justinamash is a big liability. #TrumpTrain, defeat him in primary."

The OSC determined that the tweet was posted "while invoking his official position at the White House" and therefore "this activity violated the Hatch Act."

The Hatch Act dates back to 1939 and prevents people working in the executive branch from engaging in political activity. There are a few exceptions to the rule, including the president, vice president and some other federal employees.

According to the OSC's website, the purpose of the law is "to ensure that federal programs are administered in a nonpartisan fashion, to protect federal employees from political coercion in the workplace, and to ensure that federal employees are advanced based on merit and not based on political affiliation."

In Scavino's case, he was issued a warning letter and was "counseled about the Hatch Act by the White House Counsel."

The OSC's decision in the case was made public after the watchdog group Citizens for Responsibility and Ethics in Washington (CREW) shared a letter they received after filing a complaint about the tweet with the OSC.

The group posted a picture of the letter on their Twitter feed, calling it a "Big win for CREW!"

Scavino has not tweeted about the news. ABC News has reached out to the White House for comment.

Scavino still regularly tweets from his personal account, but has also pointed out that he has an official handle as well, @scavino45.

Shortly after the tweet about Amash was posted on April 2, Scavino seemed to brush off ethics concerns, responding to a question from a fellow Twitter user by saying "What 'ethics lawyers?' The ones from the Obama Admin who want to take Trump down, or the Bush Admin who were #NeverTrump? No thanks!"

At the time of the tweet's original posting, a White House official defended it to ABC News.

"Dan Scavino's tweet does not violate the Hatch Act as it clearly comes from his personal account and not his official White House account. He created an official account upon entering the White House to ensure compliance with the Hatch Act and he has taken the necessary steps to ensure there is a clear distinction between both Twitter accounts," the official said back in April.