"I have an incredible respect for the history and tradition of NC State University, and am honored by the opportunity to lead the Wolfpack," Keatts said in a statement.
Keatts had led the Seahawks to the NCAA tournament the past two seasons. UNC Wilmington lost to Virginia in the first round Thursday.
The six-year deal with the Wolfpack is for $2.2 million annually, a spokesman said. The school will introduce Keatts in a news conference at 1 p.m. ET Sunday.
"When we set out to hire our next men's basketball coach, we wanted to identify someone with the pedigree, vision and plan to serve as the architect of NC State basketball," athletic director Debbie Yow said in a statement. "Kevin quickly emerged as the perfect fit in each of these areas. His history of success in building programs, of competing at a championship-level in every stop of his career, his commitment to player development and priority in academics make him a tremendous hire for us."
Prior to taking the job at UNC Wilmington, Keatts was an assistant under Rick Pitino at Louisville from 2011 to 2014. He was the head coach at Hargrave Military Academy in Virginia from 2003 to 2011 before being hired by Pitino.
Pitino said he had talked with Keatts earlier Friday about the NC State job, and he heaped praise on his former assistant.
"He is absolutely awesome. He is a great recruiter, he is a tremendous coach and he has a very difficult style to play against," Pitino told ESPN's Andy Katz. "He's like a little brother to me. ... I can't say enough superlatives about him.
"NC State got themselves a great one in him. Now they've got to just sit back and let the guy coach and recruit. ... And go for longevity. Let's not make any coaching changes for about 10 years."
Keatts' career mark in three seasons at UNC Wilmington is 72-28. He improved the win total of the Seahawks in each of his three seasons, including a program-record 29 victories this season. The team won CAA regular-season titles all three seasons under Keatts, who became the first coach in conference history to win back-to-back Coach of the Year accolades.
He will replace Gottfried, who was fired after six seasons in Raleigh. Gottfried took the Wolfpack to the NCAA tournament in each of his first four seasons, but the program failed to live up to expectations the past two years and finished 13th in the ACC each season.