Washington (CNN) House Speaker Paul Ryan is not seeking re-election and will retire from Congress after this year, the Wisconsin Republican announced Wednesday.

"You realize something when you take this job," Ryan told reporters on Capitol Hill on Wednesday morning. "It's a big job with a lot riding on you ... but you also know this is not a job that does not last forever. ... You realize you hold the office for just a small part of our history. So you better make the most of it."

He reminded reporters that he took the job "reluctantly" in 2015, when he took over from John Boehner, but Ryan also said he has no "regrets."

"I like to think I've done my part, my little part in history to set us on a better course," Ryan said.

Ryan's departure is a blow to GOP members who saw the Wisconsin Republican as a stable and policy-oriented leader in a party shaken by the tumultuous Donald Trump presidency. He has been a fundraising juggernaut ahead of the midterms this fall, and helped translate GOP agenda items into legislation such as a series of tax cuts and rolling back banking legislation put in place under Democrats.

In his prepared remarks, Ryan focused on the tax law that passed last year as a key legacy he left behind and spoke at length about his desire to go home to Wisconsin to be with his family. He said that the 2018 midterms and the chance that he wouldn't be speaker didn't factor at all into his decision to announce his retirement.

"None whatsoever actually," Ryan said.

Looming in the aftermath of Ryan's announcement is the reality of an impending leadership race that will now stretch for months ahead of a contentious midterm election. But Ryan downplayed that it would be a distraction.

Trump, who has at times fought with congressional Republicans including Ryan, tweeted praise for the speaker after his announcement.

"Speaker Paul Ryan is a truly good man, and while he will not be seeking re-election, he will leave a legacy of achievement that nobody can question. We are with you Paul!" Trump wrote.

How Ryan made his decision

The discussions about Ryan's future have been closely held, according to a person familiar with the decision. Along with his wife, Janna, and his three kids, Ryan has been discussing next steps with a group of roughly six close aides for the last several months.

This person said Ryan made his decision over the spring recess with his family while spending some time with them overseas after his official trip wrapped up in the Czech Republic.

"This has been a direction that he has been heading in for a while, but I will say as recently as February he has been talking about running again," this person said. Even before his biggest legislative accomplishment -- tax reform -- was across the finish line Ryan was contemplating that this would be his last term in the House.

The speaker directed his aides to never definitely say he was running for re-election, and his public comments always gave him the room to step down next year.

One thing that was always part of the speaker's calculus, and he has spoken about throughout his career, was the impact of losing his father at the age of 16.

"It's always weighed heavily on him. and at a moment like this when his kids are reaching the same age as when his father passed away, it's especially poignant," the person familiar with the decision told reporters.

Who will replace Ryan?

While it has long been expected that Ryan would leave after the 115th Congress, sources close to him have said for weeks they expected he would run again in order to raise money for the party and not throw his conference into a leadership battle. Ryan "recently" came to the conclusion that wasn't the best path for him, one of the sources said.

Add CNN's 2018 elections calendar Stay up to date on key election dates and other events, such as town halls and debates, as they get added throughout the year. Subscribe on your Google or Apple calendar.

House Majority Leader Kevin McCarthy of California and Majority Whip Steve Scalise of Louisiana are among the contenders congressional observers see as most likely to replace Ryan.

Scalise demurred when asked if he would run for the speakership.

"We're getting way ahead of ourselves. Obviously, there's a lot of speculation, but I've been real clear for a long time, I don't want to get into speculation," he told Fox News, adding, "We've got to make sure we keep the majority."

Scalise told Politico in March that he would not rule out running for the speakership if Ryan were to retire.

One source with the conservative bloc, the House Freedom Caucus, says McCarthy is, at this early stage, likely to have the support to become the next speaker with the group's chairman, Rep. Mark Meadows, a front-runner to become majority leader.

Ryan is likely to weigh in publicly on who should succeed him as speaker. The person familiar with Ryan's decision said, "He has thoughts on this and he will share those at a later time."

That source insisted that the leadership race can wait until January, and the speaker can still effectively lead the GOP conference: "He has confidence that his leadership team will be able to pull together and get the job done for the rest of the year."

Republicans say they're going to miss Ryan

Even though the Republican conference was not always unified behind Ryan, members of both parties and both chambers praised his tenure.

"Paul Ryan is a person of true integrity who I have had the great fortune to know over the last eight years," GOP Sen. Ron Johnson of Wisconsin said in a statement. "He has served Janesville, southeastern Wisconsin and our nation honorably. We should all be grateful for his sacrifice and understand his desire to be a full-time dad."

In an apparent reference to the struggles facing Ryan, Rep. Trey Gowdy released a statement both praising the retiring speaker and encouraging those who think they can do better to step up.

"To those within Congress who always seemed to have a better idea or a smarter strategy, now is your chance to run for speaker," the South Carolina Republican said in his statement. "To those outside of Congress who always seemed to have a better idea or a smarter strategy, you do not have to be a member of the House to be speaker of the House and hence, now is your chance to run for speaker."

Meadows, of North Carolina, praised Ryan's tenure in a statement after the news broke.

"Speaker Ryan has served our country well for decades as a thoughtful policy leader in the House," he told CNN. "He will be successful in any future endeavor and I wish him all the best."

Even Nancy Pelosi, the Democratic leader in the House and former speaker herself, found some kind words for her Republican counterpart.

"Despite our differences, I commend his steadfast commitment to our country," Pelosi said in a statement. "During his final months, Democrats are hopeful that he joins us to work constructively to advance better futures for all Americans."

Ryan wants to spend time with his family

According to two sources with direct knowledge, in calls this morning with his leadership team, Ryan made clear much of this decision was about spending time with his family, but also noted that he planned to leave after this Congress and didn't think it was fair to his district or the GOP conference to run for re-election only to leave right after. Sources familiar told CNN that Ryan called McCarthy and Scalise about his retirement before the news broke.

Ryan called Trump and Vice President Mike Pence on Wednesday morning ahead of his announcement, a source familiar with their conversation told CNN.

The speaker met with members of his caucus on Wednesday morning. Rep. Darrell Issa of California told CNN that Ryan told members he promises to be more than a "Sunday dad" and he cited his family as part of his decision. At one point Wednesday morning, reporters outside the conference room could hear a long applause from inside the meeting.

Ryan, a Wisconsin Republican, has been in Congress since 1999 and became House speaker in 2015. Ryan reluctantly ran to replace then-Speaker Boehner of Ohio, who retired after sparring regularly with the most conservative members of his conference, including many members of the House Freedom Caucus.

Some of Ryan's close friends previously told CNN that he might leave office after the 2018 midterms. Ryan said in a January interview with CBS News that re-election was a decision he and his wife were planning to make together in late spring, and in March he denied a rumor that he wouldn't seek re-election.

The news of Ryan's retirement was first reported by Axios.

This story has been updated with additional developments.