We are able to perform the duality transformation of the spin system which was found before as a lattice realization of the string with linear action. In four and higher dimensions this spin system can be described in terms of a two-plaquette gauge Hamiltonian. The duality transformation is constructed in geometrical and algebraic language. The dual Hamiltonian represents a new type of spin system with local gauge invariance. At each vertex ξ there are d(d − 1)/2 Ising spins Λ µ,ν = Λ ν,µ , µ = ν = 1, .., d and one Ising spin Γ on every link (ξ, ξ+e µ ). For the frozen spin Γ ≡ 1 the dual Hamiltonian factorizes into d(d − 1)/2 two-dimensional Ising ferromagnets and into antiferromagnets in the case Γ ≡ −1. For fluctuating Γ it is a sort of spin glass system with local gauge invariance. The generalization to p-branes is given.