House Speaker Paul Ryan said Tuesday he has had a good working relationship with President Donald Trump, and he denied that his decision to retire stemmed from his dealings with Trump.

The 48-year-old Wisconsin Republican, who pointedly criticized Trump during the 2016 election, said the president's election allowed him to pursue GOP policy priorities. Ryan announced plans last week to retire, months after Congress passed his long-held goal of overhauling the tax system.

"Look at what his election got us. It got us, finally, a unified government," Ryan told CNBC's "Squawk Box." "I'm grateful that he has given us this chance with his election to do fundamental tax reform that is a long time in coming that finally got done."

When Ryan announced his retirement, some reports suggested he no longer wanted to face questions about the president's erratic behavior. In 2016, Ryan slammed candidate Trump for his comments about a Mexican-American judge as well as his remarks about groping women from 2005 that surfaced just before the 2016 election.