The Islington North MP is expected to spend about an hour in the town on Monday afternoon to offer his support for Scott Redpath, the party’s candidate at Scottish Borders Council’s forthcoming Selkirkshire by-election.
The visit is unexpected as it is not anticipated that Labour can win the seat on Thursday, February 22.
Mr Redpath received less than 4% of the votes cast in last year’s local election last year, but he remains hopeful.
Mr Corbyn, also visiting Glasgow, accepted an invitation to visit the town from Jedburgh-born Ian Davidson, a Labour MP in Glasgow from 1992 to 2015 and a candidate for the Berwickshire, Roxburgh and Selkirk won by John Lamont for the Conservatives in June last year.
The Labour leader has helped transform his party since winning the leadership three years ago.
He has also become a cult figure both within and outside politics, making high-profile appearances at events around the country, including last summer’s Glastonbury Festival.
Mr Redpath, who voted for Mr Corbyn in both his leadership elections, said: “I’m very happy and proud he has found the time to come and offer my campaign his support.
“It just backs his pledge to travel the length and breadth of the country to get Labour’s message across.”
Also standing in the Selkirkshire by-election are Trevor Adams for the Conservatives, Jack Clark for the Liberal Democrats, the Green Party’s Barbra Harvie, the Scottish National Party’s John Mitchell and two independents, Kenneth Gunn and Caroline Penman.