Malan, 32, played three Tests against England in 2019-20 and was part of Warwickshire's County Championship-winning side last summer, averaging 37.66 across his six appearances for them.
"I'm very excited to be joining Middlesex," Malan said. "They are without a doubt one of the most prestigious counties and being based at Lord's makes this an incredible opportunity that I'm hoping to grab with both hands."
"We are thrilled to have secured Pieter's signature for the rest of this season," Alan Coleman, Middlesex's head of performance, said. "He will add a huge amount of experience and quality to our batting ranks. As a batter he is vastly experienced, will be a real asset to the dressing room, and we can't wait to welcome him into the club."
"I'm a little bit disappointed with how I've gone over here with the bat," he told Middlesex's YouTube channel. "I set high standards and it's quite obvious that I didn't quite make the runs that I wanted to make over here but it's great to see the way they're going about it."