President Trump chastised Attorney General Jeff Sessions on Twitter on Monday for federal indictments of two sitting Republican congressmen ahead of the midterm elections, the latest attack by a president who pledged to "drain the swamp" against the attorney general he handpicked.

"Two long running, Obama era, investigations of two very popular Republican Congressmen were brought to a well publicized charge, just ahead of the Mid-Terms, by the Jeff Sessions Justice Department," Mr. Trump wrote. "Two easy wins now in doubt because there is not enough time. Good job Jeff......"

In the last month, federal grand juries have handed down indictments for New York's Rep. Chris Collins and California's Rep. Duncan Hunter, the first and second members of Congress to endorse Mr. Trump in the 2016 campaign, respectively. Collins faces charges of insider trading and Hunter is accused of using hundreds of thousands of dollars in campaign funds on personal expenses.

Get Breaking News Delivered to Your Inbox

The charges against Collins stem from allegations he shared an illegal stock tip with his son about a pharmaceutical company where he was a board member in 2017, well after Mr. Trump took office. The indictment does not specify when the investigation into Collins began. He has suspended his re-election campaign, despite denying the charges.

The charges against Collins were announced on Aug. 8 by Geoffrey Berman, the U.S. Attorney for the Southern District of New York and a Trump appointee. Berman denied politics played a role in the decision to seek the indictment, telling reporters that "we are months away from the election, and the concerns do not apply."

Questions over Hunter's spending began in April 2016, when the FEC began scrutinizing his campaign expenditures. He and his wife Margaret were both indicted on Aug. 22 for allegedly using $250,000 in campaign funds for personal use. They pleaded not guilty.

While there is a longstanding DOJ custom of avoiding bringing charges or taking investigative steps within 60 days of when voters go to the polls, there is no formal rule forbidding federal prosecutors from doing so. In a memo to DOJ employees in 2012, then-Attorney General Eric Holder reiterated guidance from 2008 that "law enforcement officers and prosecutors may never select the timing of investigative steps or criminal charges for the purpose of affecting any election, or for the purpose of giving an advantage or disadvantage to any candidate or political party."

Both Collins and Hunter were indicted well outside the customary 60-day window.

AshLee Strong, spokeswoman for Speaker of the House Paul Ryan, said the DOJ "should always remain apolitical, and the speaker has demonstrated he takes these charges seriously."

Fellow Republican Senators Ben Sasse and Jeff Flake both blasted Mr. Trump for his latest rebuke of Sessions. Flake tweeted on Monday that it was not the conduct of "a president committed to defending and upholding the constitution, but rather a president looking to use the Department of Justice to settle political scores."

Meanwhile, Sasse compared Mr. Trump's version of the justice system to a "banana republic."

"These two men have been charged with crimes because of evidence, not because of who the president was when the investigations began. Instead of commenting on ongoing investigations and prosecutions, the job of the President of the United States is to the defend the Constitution and protect the impartial administration of justice," Sasse said in a statement Monday.

The president's tweet on Labor Day is the latest in a series of heightened attacks on Sessions, whom Mr. Trump has chastised for recusing himself from special counsel Robert Mueller's investigation and for failing to prosecute Mr. Trump's political enemies like Hillary Clinton. Mr. Trump recently claimed Sessions never took control of the DOJ, to which Sessions responded in a rare statement that he took control of the Justice Department the day he took office.

Mr. Trump has said he thinks Sessions' job is safe until the midterm elections, but in an interview with Bloomberg last week, declined to say how much longer Sessions might last.

Mr. Trump campaigned in part on a platform of draining the swamp, a key slogan in his 2016 presidential race, a phrase assumed by many to mean draining Washington of conflicts of interest and corruption.

Paula Reid contributed reporting.