Let ???=??? n (R) be the associative algebra of all n?x?n upper triangular matrices over a unital commutative ring R with n?>?2. A map s on ?? is called preserving commutativity in both directions if xy?=?yx???s(x)s(y)?=?s(y)s(x). For an invertible linear map s on ??, the following two conditions are shown to be equivalent: (a) s preserves commutativity in both directions and (b) s takes the form: s(X)?=?cS -1[?X?+?(??-?1)PX'P]S?+?f(X)I, ?X?????, where c???R is invertible, ????R is idempotent, i.e. ?2?=??, S????? is invertible, , X' means the transpose of X and f is a linear function from ?? to R such that 1?+?f(I) is invertible. This result extends the main theorem of Marcoux and Sourour [L.W. Marcoux and A.R. Sourour, Commutativity preserving linear maps and Lie automorphisms of triangular matrix algebras, Linear Algebra Appl. 288 (1999), pp. 89104] to an arbitrary commutative ring.