Brazilian title holder Dos Anjos pulled out of the Las Vegas bout after injuring a foot in training.
Featherweight champion McGregor was aiming to be the first UFC fighter to hold two world titles at the same time.
UFC president Dana White announced the reorganised fight on Tuesday night.
Californian Diaz tweeted: "He's going to have to get on his knees and beg."
McGregor knocked out Brazilian Jose Aldo in 13 seconds in December.
That victory confirmed the 27-year-old Irishman as the UFC's featherweight champion after he had held the interim title following Aldo's withdrawal from their planned fight last July.
McGregor plans to alternate between featherweight and lightweight, fighting for both belts, although his non-title bout with Diaz will be at welterweight, which is the heavier 170lb division.
Women's bantamweight champion Holly Holm is scheduled to defend her belt against Miesha Tate on the 5 March UFC 196 bill.
American Holm, 34, caused a major shock when she beat Ronda Rousey to win the title in November.
Conor McGregor will fight Nate Diaz on 5 March after his UFC lightweight world title bout with Rafael dos Anjos was called off.