Deputy U.S. Attorney General Rod Rosenstein testifies before a subcommittee hearing of the Senate Appropriations Committee on Capitol Hill in Washington, June 13, 2017.

Deputy Attorney General Rod Rosenstein said he would only consider dismissing Robert Mueller if there was good cause.

In a Tuesday hearing on the Justice Department budget for the 2018 fiscal year, Sen. Susan Collins, R-Maine, asked Rosenstein what he would do if the president asked him to fire Mueller.

Rosenstein responded, "Senator, I'm not going to follow any orders unless I believe those orders are lawful and appropriate orders. Under the regulation, special counsel Mueller may be fired only for good cause and I'm required to put that cause in writing."

When Sen. Jeanne Shaheen, D-N.H., asked Rosenstein if he has seen any reason to fire Mueller, the deputy attorney general said he had not.

In May, Rosenstein appointed former FBI Director Mueller as special counsel overseeing the investigation into Russian interference in the 2016 election.

The senators posed their questions after Chris Ruddy, the CEO of conservative website Newsmax, said President Donald Trump was considering firing Mueller. Ruddy, a close Trump ally, told PBS NewsHour on Monday that the president is weighing the option.

Ruddy said, however, that doing so would "be a very significant mistake."

— CNBC's Nyshka Chandran and Jacob Pramuk contributed to this report.