Cook scored 38 goals in 48 league games for Barrow after joining in July 2014 following his release by Grimsby.
The 25-year-old started his career with Carlisle, and had three previous spells at Barrow before joining the Mariners.
"He is a hard-working player who has consistently been scoring 20 plus goals per season, which made him one of my top priorities" boss Gary Brabin said.
"We know that we need to improve our performance in front of goal, and I am sure that Andy will play a big role in helping us to achieve that."
Tranmere have signed striker Andy Cook in a two-year free-transfer deal from National League rivals Barrow.