A source told ESPN that Underwood agreed to a six-year deal worth more than $3 million per season. He earned a little more than $1 million per season at Oklahoma State and had four years remaining on his contract.
Fighting Illini athletic director Josh Whitman welcomed Underwood to the program in a tweet Saturday afternoon.
"In searching for a new coach, we were looking for a proven winner who would build upon our proud tradition while developing an unmistakable identity for Illinois Basketball," Whitman said in a statement. "Brad's teams play a fast, aggressive style and show unyielding toughness."
The Cowboys hired Underwood a year ago, and he took the program to the NCAA tournament this season, losing to Michigan in the first round Friday. Previously, he had spent three seasons at Stephen F. Austin, with trips to the NCAA tournament all three years and two first-round wins.
"Coaching basketball at the University of Illinois is a once-in-a-lifetime opportunity," Underwood said in a statement. "The players, fans and administration at Oklahoma State have been absolutely incredible, and I want to thank them for the support they've given me and my family over the last year. However, during my time at Western Illinois, I always saw the Illinois coaching job as one of the truly best in the nation. I want to thank Josh Whitman for the opportunity to join the Fighting Illini family and look forward to working with him to build a championship program."
Underwood was as an assistant coach at Western Illinois for 11 seasons and spent one season as the associate head coach at both Kansas State and South Carolina before landing at Stephen F. Austin. The 53-year-old has a 109-27 record as a head coach.
He returned to Stillwater with the Cowboys on Friday night following the loss to the Wolverines, an Oklahoma State official told ESPN's Andy Katz. The official was stunned to learn via Twitter that Underwood was going to Illinois, saying there was no indication he was leaving Oklahoma State.
"We are saddened and disappointed in Brad's decision to leave Oklahoma State after one year," Cowboys athletic director Mike Holder said in a statement. "We are trying to digest the news.
"We wish Brad and his family well. In the meantime, we will consider the situation and move forward."
Underwood will replace John Groce in Champaign. Groce was 95-75 in five seasons but made the NCAA tournament just once.
The Illini have reached the second round of the NIT and will face Boise State on Monday. Jamall Walker will continue to serve as Illinois' interim head coach throughout the postseason, and Underwood will attend Monday's game as a spectator.
Oklahoma State went through an up-and-down season in Stillwater. After starting 10-2, the Cowboys endured a six-game losing streak to open Big 12 play before turning things around with 10 wins in 11 games. But the season finished on a sour note, with two straight losses to finish the regular season plus losses in their first game of the Big 12 and NCAA tournaments.
The Cowboys were a top-10 team in scoring during the regular season, averaging 85.5 points per game. Oklahoma State's offensive efficiency was ranked No. 1 by Ken Pomeroy.
Underwood finished second to Kansas' Bill Self in Big 12 Coach of the Year voting.
Self, whose first Power 5 head-coaching job was at Illinois, described the news of Underwood's departure as a shock.
"You see a lot of coaching changes across America, but very rarely do you see one after just one year," Self said. "Granted, Brad is a really good guy and did a great job. But from the outside looking in, it looked to me like OSU and Brad fit very, very well."
The Associated Press contributed to this report.