Manager Manny Acta says Mike MacDougal will take over the role.
Hanrahan is 0-3 with a 6.84 ERA in 27 games. He started the season as the closer, was demoted to middle relief in late April, then restored to the post in mid-May.
The 27-year-old right-hander has allowed runs in each of his last three outings. He took the loss after giving up two runs in the 10th inning of Friday night's loss to the New York Mets.
MacDougal has yet to allow a run in four appearances with the Nationals. The organization signed him to a minor league deal in May.
Acta made the announcement before Saturday night's game against New York.