The arrival of Fernando comes after the free transfer of Arsenal right-back Bacary Sagna. He gives City manager Manuel Pellegrini an extra midfield option in addition to Yaya Toure, Fernandinho, Javi Garcia and Jack Rodwell.
"I am so happy to finally be joining Manchester City," Fernando told City's website. "I know there was talk of me possibly signing last January so I am delighted that the deal has now been done and that I am a City player."
Fernando is currently on holiday in Brazil, but will report for pre-season training in a fortnight, City said.
"I'm looking forward to meeting my new team-mates and helping City to defend the title," he continued. "It is a very exciting time to be part of this football club and I cannot wait to play in the Premier League.
"City fans can be assured I will give my all everytime I play and I'm looking forward to many happy years in Manchester. I have enjoyed my stay with Porto and I thank the club and the fans for their support during my time in Portugal. Now I am ready for a new chapter in my career."
Fernando moved to Porto in 2007 from Brazilian club Vila Nova, and after a loan spell with Estrela da Amadora, went on to win the Portuguese title four times while adding two Portuguese Cups and a Europa League medal.