Ceballos, 22, was also subject to an approach by North London rivals Spurs and becomes Arsenal's first big-name signing of the summer, with the club having failed thus far to land Crystal Palace's Wilfried Zaha and Celtic's Kieran Tierney.
"We're excited to see Dani join us," Arsenal boss Unai Emery said. "He is a talented player with big technical ability, creativity and precision."
Sources told ESPN FC that Emery had been decisive in Ceballos accepting Arsenal's proposal even though they won't participate in the Champions League this season.
Ceballos impressed for Spain in the European Under-21 Championship in July, scoring two goals as well as being named in the Team of the Tournament.
The midfielder, who will wear the No. 8 shirt, made 23 league appearances in Real Madrid's tough La Liga campaign last season, scoring three goals. He also made three Champions League appearances.
Ceballos began his career at Real Betis before moving to Madrid in 2017.
Emery said on Sunday that he was happy for the Gunners to wait in the transfer market until the right players come available after saying last week that he was after "very big, very expensive" signings.
Even with the signing of Ceballos, Arsenal are yet to spend big money this window -- Brazilian teenager Gabriel Martinelli is their only other signing this window -- as the club battle growing fan unrest at the lack of financial investment from owner Stan Kroenke, which culminated in an angry two-page letter being sent from Arsenal supporters' groups to the club board.
Later on Thursday, Arsenal completed another deal with the signing of Saliba in a deal worth €30m before being loaned back to Saint-Etienne for the upcoming season.
"We're delighted William is joining us," Emery said in a statement. "Many teams wanted him, but he decided he wanted to come to us and be part of our future.
"He will stay in France next season for more experience and then we look forward to him joining our group."
Saliba, who signed his first contract at the age of 17, made his professional debut with Saint-Etienne against Toulouse last September and finished the campaign with 14 league starts under his belt.
"This is the biggest club in England for me, so it was an easy decision," Saliba said. "I didn't think twice about signing here, so I'm really happy.
"This is a big club, and when you come here, you need to be ready. So I'm going to try to have a great season with the club that developed me in order to be ready for Arsenal."