Cadena SER have reported that Khedira, whose contract expires with the La Liga side at the end of the season, has agreed a deal with Per Guardiola's team which begins next summer.
Both London clubs had been linked with the German World Cup winner during this summer, with his salary demands reportedly putting off the Gunners.
The news comes just as Khedira has become an integral part of the Real squad again, with Luka Modric out for three months injured.
Khedira will have been at Real for five seasons, after joining from Stuttgart in 2010.
Watch the latest transfer updates on Sami Khedira below...
The 27-year-old has made 150 appearances for Real in all competitions, and won the La Liga title with the club in 2013, plus the Champions League in 2014.
Only yesterday, Arsenal defender Per Mertesacker revealed in a question and answer session that he had spoken to his international team-mate about joining the Gunners.
"I'm up to more quality Germans to the club," he said. "[Mesut] Ozil and I spoke with Khedira a few times to join Arsenal. His contract is up next summer."
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies