The software giant ended Friday with a market value of more than $851bn (£668bn) compared with Apple's $847bn.
The two firms have been vying for top place all week, with Apple remaining ahead at the end of each trading day.
But the iPhone maker, which has seen its share price plunge in recent weeks, finally lost its lead.
On Friday, Microsoft shares gained more than 0.6% to close at $110.89, while Apple shares finished at $178.60, down about 0.5%.